public function CheckoutSdk::updateOrder in Commerce PayPal 8
Updates an existing PayPal order.
Parameters
string $remote_id: The PayPal order ID.
\Drupal\commerce_order\Entity\OrderInterface $order: The order.
Return value
\Psr\Http\Message\ResponseInterface The HTTP response.
Overrides CheckoutSdkInterface::updateOrder
File
- src/
CheckoutSdk.php, line 132
Class
- CheckoutSdk
- Provides a replacement of the PayPal SDK.
Namespace
Drupal\commerce_paypalCode
public function updateOrder($remote_id, OrderInterface $order) {
$params = $this
->prepareOrderRequest($order);
$update_params = [
[
'op' => 'replace',
'path' => "/purchase_units/@reference_id=='default'",
'value' => $params['purchase_units'][0],
],
];
$event = new CheckoutOrderRequestEvent($order, $update_params);
$this->eventDispatcher
->dispatch(PayPalEvents::CHECKOUT_UPDATE_ORDER_REQUEST, $event);
return $this->client
->patch(sprintf('/v2/checkout/orders/%s', $remote_id), [
'json' => $event
->getRequestBody(),
]);
}