The following code is based on the example at Webform PayPal Integration in Drupal 7
$paypal = array();
$paypal['cmd'] = '_xclick';
$paypal['business'] = variable_get('event_reg_paypal_address');
$paypal['receiver_email'] = $paypal['business'];
$paypal['page_style'] = 'huang_checkout';
$paypal['amount'] = variable_get('event_reg_paypal_cost');
$paypal['currency_code'] = 'GBP';
$paypal['item_name'] = 'Test Event Registration';
$paypal['tax'] = 0;
$paypal['custom'] = $submission->sid;
$paypal['return'] = $base_url.'/test/thanks';
$paypal['notify_url'] = $base_url.'/test/thanks';
$paypal['cancel_return'] = $base_url;
$paypal['first_name'] = //first name from submission
$paypal['country'] = 'UK';
$query = http_build_query($paypal, '', '&');
$url = $paypal_host . $query;
drupal_goto($url);
it's part of a custom module's code and implements hook_webform_submission_insert()
. when the form is submitted the $url
variable is built up from the $paypal
array and then the user's browser redirected to, for example,
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=pete27_11_94-facilitator%40hotmail.com&receiver_email=pete27_11_94-facilitator%40hotmail.com&page_style=huang_checkout&amount=0.01&currency_code=GBP&item_name=Test+Event+Registration&tax=0&custom=24&return=http%3A%2F%2Fwww.pitmart.com%2Fformulak%2Ftest%2Fthanks&notify_url=http%3A%2F%2Fwww.pitmart.com%2Fformulak%2Ftest%2Fthanks&cancel_return=http%3A%2F%2Fwww.pitmart.com%2Fformulak&first_name=sdfgsdfg&country=UK
in my paypal developers account there is a user with the email address as in the url, of type business-pro but each time i submit i get the error message
We cannot process this transaction because there is a problem with the PayPal email address supplied by the seller. Please contact the seller to resolve the problem. If this payment is for an eBay listing, you can contact the seller via the "Ask Seller a Question" link on the listing page. When you have the correct email address, payment can be made at www.paypal.com.
i'm testing on a live server, not inaccessible local.
i was expecting to be taken to a paypal login form but just get the error.
is it possible to pass data to paypal in this manner? (directly in a url rather than 'posted' by a form)
am i missing some variables/data that would cause this failure? is there documentation which lists the minimal configuration for such a paypal request?
edit - was missing currency_code
. since added that in and still receiving the error.