From d7577b001ce7109cedf128e92a69ebd41a250356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 2 Aug 2021 15:49:50 +0200 Subject: [PATCH] Extract convertToMolieAmount method --- app/PaymentDrivers/Mollie/CreditCard.php | 2 +- app/PaymentDrivers/MolliePaymentDriver.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/Mollie/CreditCard.php b/app/PaymentDrivers/Mollie/CreditCard.php index 16741b1c72..75f87fff28 100644 --- a/app/PaymentDrivers/Mollie/CreditCard.php +++ b/app/PaymentDrivers/Mollie/CreditCard.php @@ -52,7 +52,7 @@ class CreditCard public function paymentResponse(PaymentResponseRequest $request) { // TODO: Unit tests. - $amount = number_format((float) $this->mollie->payment_hash->data->amount_with_fee, 2, '.', ''); + $amount = $this->mollie->convertToMollieAmount((float) $this->mollie->payment_hash->data->amount_with_fee); $this->mollie->payment_hash ->withData('gateway_type_id', GatewayType::CREDIT_CARD) diff --git a/app/PaymentDrivers/MolliePaymentDriver.php b/app/PaymentDrivers/MolliePaymentDriver.php index 60c27321e8..44d6dcfac8 100644 --- a/app/PaymentDrivers/MolliePaymentDriver.php +++ b/app/PaymentDrivers/MolliePaymentDriver.php @@ -115,7 +115,7 @@ class MolliePaymentDriver extends BaseDriver public function refund(Payment $payment, $amount, $return_client_response = false) { - return $this->payment_method->yourRefundImplementationHere(); + } public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) @@ -192,4 +192,15 @@ class MolliePaymentDriver extends BaseDriver ); } } + + /** + * Convert the amount to the format that Mollie supports. + * + * @param mixed|float $amount + * @return string + */ + public function convertToMollieAmount($amount): string + { + return \number_format((float) $amount, 2, '.', ''); + } }