function commerce_paypal_checkout_create_order in Commerce PayPal 7.2
Page callback: Provide the createOrder() callback expected by the SDK.
1 string reference to 'commerce_paypal_checkout_create_order'
- commerce_paypal_checkout_menu in modules/
checkout/ commerce_paypal_checkout.module - Implements hook_menu().
File
- modules/
checkout/ commerce_paypal_checkout.module, line 493 - Implements PayPal Checkout in Drupal Commerce checkout.
Code
function commerce_paypal_checkout_create_order($order, $payment_method) {
$settings = $payment_method['settings'];
$api_client = commerce_paypal_checkout_api_client($settings);
if (!$api_client) {
drupal_json_output(array());
drupal_exit();
}
try {
$request_body = commerce_paypal_checkout_prepare_order_request($order, $payment_method['settings']);
drupal_alter('commerce_paypal_checkout_create_order_request', $request_body, $order);
$json = $api_client
->createOrder($request_body);
drupal_json_output(array(
'id' => $json['id'],
));
drupal_exit();
} catch (\Exception $exception) {
watchdog_exception('commerce_paypal_checkout', $exception);
}
drupal_json_output(array());
drupal_exit();
}