diff --git a/src/Payment/MolliePayment.php b/src/Payment/MolliePayment.php index 72d473ae..8f5a2877 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; }