Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NTR: Fix saved credit card payment #688

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Facade/MolliePaymentDoPay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
10 changes: 10 additions & 0 deletions src/Struct/CustomerStruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
];
Expand Down
Loading