I use the following code:
$enableSandbox = true;
$paypalConfig = [ 'email' => 'test-facilitator@gmail.com',
'return_url' => 'http://test.com/paypal/?back',
'cancel_url' => 'http://test.com/paypal/?cancel',
'notify_url' => 'http://test.com/paypal/?notify'];
$paypalUrl = $enableSandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
$itemName = 'Call';
$itemAmount = 5.00;
$data = [];
foreach ($_POST as $key => $value) {
$data[$key] = stripslashes($value);
}
$data['business'] = $paypalConfig['email'];
$data['return'] = stripslashes($paypalConfig['return_url']);
$data['cancel_return'] = stripslashes($paypalConfig['cancel_url']);
$data['notify_url'] = stripslashes($paypalConfig['notify_url']);
$data['item_name'] = $itemName;
$data['amount'] = $itemAmount;
$data['currency_code'] = 'GBP';
$queryString = http_build_query($data);
header('location:' . $paypalUrl . '?' . $queryString);
exit();
But after use, I am redirected to paypal.com home, and I am not receiving any error messages:
I also tested test-buyer@gmail.com
, but it does not work.
How can I solve this problem?
Please update your code
$paypalConfig = [ 'email' => 'test-facilitator@gmail.com',
'return_url' => 'http://test.com/paypal/?back',
'cancel_url' => 'http://test.com/paypal/?cancel',
// Added new line
'cmd' => '_xclick',
'notify_url' => 'http://test.com/paypal/?notify'];
After foreach
loop add
Added new line
$data['cmd'] = $paypalConfig['cmd'];
Then try hope it will work.
Because you are missing : Buy Now buttons — <INPUT TYPE="hidden" name="cmd" value="_xclick">
Please manage this and send cmd
in your form-builder, it should work. Please let me know if not work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.