Skip to content

Commit

Permalink
Prevent birth field check for other payment methods
Browse files Browse the repository at this point in the history
  • Loading branch information
inpsyde-maticluznar committed Jan 11, 2024
1 parent 158b145 commit 9ff37e4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class GatewayModule implements ServiceModule, ExecutableModule
protected $pluginId;

const FIELD_IN3_BIRTHDATE = 'billing_birthdate';
const GATEWAY_NAME_IN3 = "mollie_wc_gateway_in3";

public function services(): array
{
Expand Down Expand Up @@ -641,15 +642,18 @@ public function in3FieldsMandatory($fields, $errors)
*/
public function in3FieldsMandatoryPayForOrder(Order $order)
{
$paymentMethod = filter_input(INPUT_POST, 'payment_method', FILTER_SANITIZE_SPECIAL_CHARS) ?? false;

if ($paymentMethod !== self::GATEWAY_NAME_IN3) {
return;
}

$birthdateValue = filter_input(INPUT_POST, self::FIELD_IN3_BIRTHDATE, FILTER_SANITIZE_SPECIAL_CHARS) ?? false;
if (!$birthdateValue) {
wc_add_notice(
sprintf(
__(
'Error processing %1$s payment, the birthdate field is required.',
'mollie-payments-for-woocommerce'
),
$order->get_payment_method_title()
__(
'Error processing the payment, the birthdate field is required.',
'mollie-payments-for-woocommerce'
),
'error'
);
Expand Down

0 comments on commit 9ff37e4

Please sign in to comment.