From 6f04f1ee6832d4cabb5f477e30ebf6ce57640588 Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Wed, 17 Jan 2024 15:55:49 +0100 Subject: [PATCH] NTR: Fix saved credit card payment --- src/Facade/MolliePaymentDoPay.php | 6 ++++++ src/Struct/CustomerStruct.php | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/Facade/MolliePaymentDoPay.php b/src/Facade/MolliePaymentDoPay.php index d1ae2bb3e..171d97b7d 100644 --- a/src/Facade/MolliePaymentDoPay.php +++ b/src/Facade/MolliePaymentDoPay.php @@ -8,6 +8,7 @@ use Kiener\MolliePayments\Exception\MollieOrderCancelledException; use Kiener\MolliePayments\Exception\MollieOrderExpiredException; use Kiener\MolliePayments\Exception\PaymentUrlException; +use Kiener\MolliePayments\Handler\Method\CreditCardPayment; use Kiener\MolliePayments\Handler\Method\PosPayment; use Kiener\MolliePayments\Handler\PaymentHandler; use Kiener\MolliePayments\Service\CustomerService; @@ -256,6 +257,11 @@ public function startMolliePayment(string $paymentMethod, AsyncPaymentTransactio $checkoutURL .= '&cs=' . urlencode($molliePaymentData->getChangeStatusUrl()); } } + + # if we save credit card information, we do not get a checkout url, so we have to use transactionStruct + if ($paymentHandler instanceof CreditCardPayment) { + $checkoutURL = $transactionStruct->getReturnUrl(); + } } return new MolliePaymentPrepareData((string)$checkoutURL, (string)$molliePaymentData->getId()); diff --git a/src/Struct/CustomerStruct.php b/src/Struct/CustomerStruct.php index 23d6e99f8..58a5bd941 100644 --- a/src/Struct/CustomerStruct.php +++ b/src/Struct/CustomerStruct.php @@ -30,6 +30,11 @@ class CustomerStruct extends Struct */ private $creditCardToken; + /** + * @var bool + */ + private $shouldSaveCardDetail; + /** * TODO: we need to get rid off this one day, no magic -> we need to explicitly load the values from the MySQL JSON * @param string $key @@ -155,6 +160,11 @@ public function toCustomFieldsArray(): array $mollieData['credit_card_token'] = (string)$this->creditCardToken; } + if (!empty($this->shouldSaveCardDetail)) { + $mollieData['shouldSaveCardDetail'] = $this->shouldSaveCardDetail; + } + + $fullCustomField = [ 'mollie_payments' => $mollieData ];