TEster
TEster

Reputation: 359

How to return customer info from paypal?

I understand this can be done.

Here's what I've tried:

$request = curl_init();

// Set request options
curl_setopt_array($request, array
(
    CURLOPT_URL => 'https://www.paypal.com/cgi-bin/webscr',
    CURLOPT_POST => TRUE,
    CURLOPT_POSTFIELDS => http_build_query(array
    (
        'cmd' => '_notify-synch',
        'tx' => $tx,
        'at' => "xxxxxxxxxxxxxxxxx",
    )),
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_HEADER => FALSE,
    // CURLOPT_SSL_VERIFYPEER => TRUE,
    // CURLOPT_CAINFO => 'cacert.pem',
));

// Execute request and get response and status code
$response = curl_exec($request);
$status   = curl_getinfo($request, CURLINFO_HTTP_CODE);
var_dump($response);
die();
// Close connection
curl_close($request);

When I send the curl request to https://www.paypal.com/cgi-bin/webscr, I recieve this error:

"FAIL Error: 4003"

When I send it to https://www.sandbox.paypal.com/cgi-bin/webscr, It returns nothing and a status of 0.

My account is sandbox at the moment. I've had this working but it doesn't work anymore.

Can someone please help.

Thanks

Upvotes: 2

Views: 77

Answers (1)

peixotorms
peixotorms

Reputation: 1283

Usually, we return customer information only when Paypal calls back the ipn on your website.

You can use:

https://github.com/Quixotix/PHP-PayPal-IPN

For testing, you can use GET to redirect buyers to paypal, something like this:

# redirect to paypal
$redirect = 'https://www'.$addsand.'.paypal.com/cgi-bin/webscr?rm=2&cmd=_xclick&txn_type=express_checkout&no_note=1&no_shipping=1&return='.$return.'&cancel_return='.$cancel_return.'&notify_url='.$notify_url.'&image_url='.$image_url.'&business='.$paypaluser.'&currency_code='.$paypalcurrency.'&amount='.$price.'&mc_gross='.$price.'&item_name='.$product.'&item_number='.$planid.'&custom='.$uid; header("Location: $redirect"); exit(); 

Upvotes: 1

Related Questions