From 023c9b9f71efa51a881f543eb87c188fe221bd87 Mon Sep 17 00:00:00 2001 From: Marija Date: Tue, 19 Nov 2024 08:39:21 +0100 Subject: [PATCH] Add amount to UpdatePaymentDetailsResponse CS-6098 --- .../AdyenAPI/Checkout/Payments/Http/Proxy.php | 11 +++++++++-- .../Models/UpdatePaymentDetailsResult.php | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/BusinessLogic/AdyenAPI/Checkout/Payments/Http/Proxy.php b/src/BusinessLogic/AdyenAPI/Checkout/Payments/Http/Proxy.php index f87dd4b..17cf610 100644 --- a/src/BusinessLogic/AdyenAPI/Checkout/Payments/Http/Proxy.php +++ b/src/BusinessLogic/AdyenAPI/Checkout/Payments/Http/Proxy.php @@ -7,6 +7,9 @@ use Adyen\Core\BusinessLogic\AdyenAPI\Checkout\Payments\Requests\PayPalUpdateOrderHttpRequest; use Adyen\Core\BusinessLogic\AdyenAPI\Checkout\Payments\Requests\UpdatePaymentDetailsHttpRequest; use Adyen\Core\BusinessLogic\AdyenAPI\Http\Authorized\AuthorizedProxy; +use Adyen\Core\BusinessLogic\Domain\Checkout\PaymentRequest\Exceptions\InvalidCurrencyCode; +use Adyen\Core\BusinessLogic\Domain\Checkout\PaymentRequest\Models\Amount\Amount; +use Adyen\Core\BusinessLogic\Domain\Checkout\PaymentRequest\Models\Amount\Currency; use Adyen\Core\BusinessLogic\Domain\Checkout\PaymentRequest\Models\AvailablePaymentMethodsResponse; use Adyen\Core\BusinessLogic\Domain\Checkout\PaymentRequest\Models\PaymentMethodCode; use Adyen\Core\BusinessLogic\Domain\Checkout\PaymentRequest\Models\PaymentMethodResponse; @@ -55,6 +58,7 @@ public function startPaymentTransaction(PaymentRequest $request): StartTransacti * @return UpdatePaymentDetailsResult * * @throws HttpRequestException + * @throws InvalidCurrencyCode */ public function updatePaymentDetails(UpdatePaymentDetailsRequest $request): UpdatePaymentDetailsResult { @@ -65,7 +69,10 @@ public function updatePaymentDetails(UpdatePaymentDetailsRequest $request): Upda $response['pspReference'] ?? null, $response['donationToken'] ?? '', $response['merchantReference'] ?? '', - $response['paymentMethod']['type'] ?? '' + $response['paymentMethod']['type'] ?? '', + isset($response['amount']) ? + Amount::fromInt($response['amount']['value'], Currency::fromIsoCode($response['amount']['currency'])) : + null ); } @@ -113,7 +120,7 @@ public function paypalUpdateOrder(PayPalUpdateOrderRequest $request): PayPalUpda */ private function transformPaymentMethodsResponse(array $response): array { - return array_map(static function(array $method) { + return array_map(static function (array $method) { $type = $method['type'] ?? ''; $brand = $method['brand'] ?? ''; diff --git a/src/BusinessLogic/Domain/Checkout/PaymentRequest/Models/UpdatePaymentDetailsResult.php b/src/BusinessLogic/Domain/Checkout/PaymentRequest/Models/UpdatePaymentDetailsResult.php index 47f9381..4c9a81c 100644 --- a/src/BusinessLogic/Domain/Checkout/PaymentRequest/Models/UpdatePaymentDetailsResult.php +++ b/src/BusinessLogic/Domain/Checkout/PaymentRequest/Models/UpdatePaymentDetailsResult.php @@ -50,6 +50,7 @@ public function __construct( $this->donationToken = $donationToken; $this->merchantReference = $merchantReference; $this->paymentMethod = $paymentMethod; + $this->amount = $amount; } /**