From 1d641fad7a1031fcfe6026338a16bc96c015f5a3 Mon Sep 17 00:00:00 2001 From: Matic Luznar Date: Wed, 2 Aug 2023 17:38:31 +0200 Subject: [PATCH] Send dueDate to Mollie. --- src/Payment/MolliePayment.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Payment/MolliePayment.php b/src/Payment/MolliePayment.php index 72d473ae2..8f5a2877c 100644 --- a/src/Payment/MolliePayment.php +++ b/src/Payment/MolliePayment.php @@ -69,6 +69,7 @@ public function getPaymentRequestData($order, $customerId, $voucherDefaultCatego $storeCustomer = $settingsHelper->shouldStoreCustomer(); $gateway = wc_get_payment_gateway_by_order($order); + $gatewaySettings = property_exists($gateway, "settings") ? $gateway->settings : []; if (!$gateway || !($gateway instanceof MolliePaymentGateway)) { return ['result' => 'failure']; @@ -122,6 +123,19 @@ public function getPaymentRequestData($order, $customerId, $voucherDefaultCatego $encodedApplePayToken = json_encode($applePayToken); $paymentRequestData['applePayPaymentToken'] = $encodedApplePayToken; } + + if ( + $gateway->id === "mollie_wc_gateway_banktransfer" && + !empty($gatewaySettings["activate_expiry_days_setting"]) && + $gatewaySettings["activate_expiry_days_setting"] === 'yes' && + !empty($gatewaySettings["order_dueDate"]) && + is_numeric($gatewaySettings["order_dueDate"]) + ) { + $dueDateTimestamp = time() + (intval($gatewaySettings["order_dueDate"]) * 24 * 60 * 60); + // https://docs.mollie.com/reference/v2/payments-api/create-payment#bank-transfer + $paymentRequestData["dueDate"] = date("Y-m-d", $dueDateTimestamp); + } + return $paymentRequestData; }