I have integrated PayPal in my WordPress site. All the required parameters are fetched and user is redirected to PayPal. The code is as follows:
$fields = array(
'item_name' => 'item_name_01',
'item_number' => 'item_number_01',
'cmd' => urlencode('_s-xclick'),
'hosted_button_id' => urlencode('UYRL3AXNCTXCL'),
'amount' => 100
);
foreach ($fields as $key => $value) {
$fields_string .= $key . '=' . $value . '&';
}
rtrim($fields_string, '&');
$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?' . $fields_string;
header('Location: ' . $url);
exit();
This works most of the times but sometimes, 'item_number' and 'amount' doesn't show up when redirected to PayPal. This behaviour is random and I can't exactly find when that happens and when it doesn't.
Any help is appreciated. Thanks in advance.