public function CheckoutSdk::createOrder in Commerce PayPal 8
Creates an order in PayPal.
Parameters
\Drupal\commerce_order\Entity\OrderInterface $order: The order.
\Drupal\address\AddressInterface $billing_address: (optional) A billing address to pass to PayPal as the payer information. This is used in checkout to pass the entered address that is not yet submitted and associated to the order.
Return value
\Psr\Http\Message\ResponseInterface The HTTP response.
Overrides CheckoutSdkInterface::createOrder
File
- src/
CheckoutSdk.php, line 115
Class
- CheckoutSdk
- Provides a replacement of the PayPal SDK.
Namespace
Drupal\commerce_paypalCode
public function createOrder(OrderInterface $order, AddressInterface $billing_address = NULL) {
$params = $this
->prepareOrderRequest($order, $billing_address);
$event = new CheckoutOrderRequestEvent($order, $params);
$this->eventDispatcher
->dispatch(PayPalEvents::CHECKOUT_CREATE_ORDER_REQUEST, $event);
return $this->client
->post('/v2/checkout/orders', [
'json' => $event
->getRequestBody(),
]);
}