function commerce_paypal_ec_submit_form_submit in Commerce PayPal 7.2
Payment method callback: submit form submission.
File
- modules/
ec/ commerce_paypal_ec.module, line 677 - Implements PayPal Express Checkout in Drupal Commerce checkout.
Code
function commerce_paypal_ec_submit_form_submit($payment_method, $pane_form, $pane_values, $order, $charge) {
// Update the order to reference the PayPal Express Checkout payment method.
$order->data['payment_method'] = $payment_method['instance_id'];
// Generate a payment redirect key.
$order->data['payment_redirect_key'] = drupal_hash_base64(time());
// Request a token from Express Checkout.
$token = commerce_paypal_ec_set_express_checkout($payment_method, $order, 'mark');
// If we got one back...
if (!empty($token)) {
// Set the Express Checkout data array and proceed to the redirect page.
$order->data['commerce_paypal_ec'] = array(
'flow' => 'mark',
'token' => $token,
'payerid' => FALSE,
);
return TRUE;
}
else {
// Otherwise show an error message and remain on the current page.
drupal_set_message(t('Communication with PayPal Express Checkout failed. Please try again or contact an administrator to resolve the issue.'), 'error');
return FALSE;
}
}