1

I'm trying to send PayPal POST data to a Mautic form as in this guide.

The only change I made to the code in the example is removing the IP forwarding stuff.

My code seems to be connecting to Mautic and sending the data, as Mautic is creating a new contact in the form submission, but it is only logging the IP address and date of creation - none of the fields are filled in. I tried logging the response from Mautic, and I'm getting a redirect to the form submitted message and an HTTP code 302.

Here is the code I'm using to send data to the function:

//collect contact details
$payer_email = $_POST['payer_email'];
$given_name = $_POST['first_name'];
$surname = $_POST['last_name'];
$phone = $_POST['contact_phone'];

//build array and forward to mautic
$_REQUEST = array('Given name' => $given_name, 'Surname' => $surname, 'Email' => $payer_email, 'Phone' => $phone);
pushMauticForm($_REQUEST, 4);
}

which produces an array like this:

[Email] => buyer@paypalsandbox.com
[Given name] => John
[Surname] => Smith
[Phone] => 

The field names match my form field labels, and are in the same order.

I feel like I'm missing something simple, but I just can't figure out what it is. Any ideas?

Stephan
  • 41,764
  • 65
  • 238
  • 329
Elenchus
  • 195
  • 2
  • 10

2 Answers2

1

It's because you are being redirected. Add the following in pushMauticForm to follow redirects.

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
v7d8dpo4
  • 1,399
  • 8
  • 9
  • 1
    Thanks for your response. I added your code, and also picked up a typo in mine that would have affected things, but I'm getting nearly the same result. Only difference is that I'm receiving an http code 200 instead of 302, and the response is several scripts in a blank html page (I can't figure out the purpose of them) instead of the redirect - still no fields filled in Mautic. I had thought about the redirect, but assumed that because it was to the form submitted message that everything should have happened already anyway? – Elenchus Jun 21 '16 at 03:09
1

My guess is that you try to send the field labels, but Mautic needs the field aliases. Try something like this:

pushMauticForm(
    array(
        'payer_email' => $_POST['payer_email'],
        'given_name' => $_POST['first_name'],
        'surname' => $_POST['last_name'],
        'phone' => $_POST['contact_phone'],
    ),
    4
);

Double check the real aliases. The best way to do that is probably when you click in the Form detail page the Manual Copy button where you can see the generated HTML of the form. The aliases are there in the <input name="mauticform[>>alias_is_here<<]"/> tags.

John Linhart
  • 1,746
  • 19
  • 23
  • 1
    Thank you very much John, and for your guide. I thought it might be something like that, but I couldn't find any other name for the fields within Mautic except the label. Manual Copy did the trick. For anyone who stumbles on this later, in the generated HTML you'll find something – Elenchus Jun 21 '16 at 11:38