Skip to content

Commit

Permalink
Fix UpdatePayPalOrderCommandHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt75 committed Aug 19, 2024
1 parent df8febf commit b1920ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,16 @@ public function handle(UpdatePayPalOrderCommand $command)
$builder->buildMinimalPayload();
}

$response = $this->httpClient->updateOrder($builder->presentPayload()->getArray());
$order = json_decode($response->getBody(), true);
$payload = $builder->presentPayload()->getArray();
$response = $this->httpClient->updateOrder($payload);

if ($response->getStatusCode() !== 204) {
throw new PayPalOrderException('Failed to update PayPal Order', PayPalOrderException::PAYPAL_ORDER_UPDATE_FAILED);
}

$this->eventDispatcher->dispatch(new PayPalOrderUpdatedEvent(
$order['id'],
$order,
$command->getPayPalOrderId()->getValue(),
$payload,
$command->getCartId()->getValue(),
$command->isHostedFields(),
$command->isExpressCheckout(),
Expand Down
4 changes: 1 addition & 3 deletions src/PayPal/Order/Exception/PayPalOrderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,5 @@ class PayPalOrderException extends PsCheckoutException
const INVALID_ID = 1;
const CANNOT_RETRIEVE_ORDER = 2;
const EMPTY_ORDER_DATA = 3;
const CANNOT_CAPTURE_ORDER = 4;
const SESSION_EXCEPTION = 5;
const CACHE_EXCEPTION = 6;
const PAYPAL_ORDER_UPDATE_FAILED = 4;
}

0 comments on commit b1920ed

Please sign in to comment.