From 12d37359e19739948c1660551956d963739beff5 Mon Sep 17 00:00:00 2001 From: DouglasCorreiaMeli Date: Wed, 10 Jan 2024 18:10:21 -0300 Subject: [PATCH] feat: :sparkles: Check blocks payment on each gateway --- src/Gateways/BasicGateway.php | 6 ++++++ src/Gateways/CreditsGateway.php | 6 ++++++ src/Gateways/CustomGateway.php | 2 ++ src/Gateways/PixGateway.php | 7 ++++++- src/Gateways/TicketGateway.php | 10 +++++++--- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/Gateways/BasicGateway.php b/src/Gateways/BasicGateway.php index 6095602d0..fd39fa3a3 100644 --- a/src/Gateways/BasicGateway.php +++ b/src/Gateways/BasicGateway.php @@ -310,6 +310,12 @@ public function process_payment($order_id): array try { parent::process_payment($order_id); + if (isset($_POST['wc-woo-mercado-pago-basic-new-payment-method'])) { + $this->mercadopago->orderMetadata->markPaymentAsBlocks($order, "yes"); + } else { + $this->mercadopago->orderMetadata->markPaymentAsBlocks($order, "no"); + } + $this->transaction = new BasicTransaction($this, $order); $method = $this->mercadopago->hooks->options->getGatewayOption($this, 'method', 'redirect'); diff --git a/src/Gateways/CreditsGateway.php b/src/Gateways/CreditsGateway.php index c0fbf3882..67fdbaeb6 100644 --- a/src/Gateways/CreditsGateway.php +++ b/src/Gateways/CreditsGateway.php @@ -241,6 +241,12 @@ public function process_payment($order_id): array try { parent::process_payment($order_id); + if (isset($_POST['wc-woo-mercado-pago-credits-new-payment-method'])) { + $this->mercadopago->orderMetadata->markPaymentAsBlocks($order, "yes"); + } else { + $this->mercadopago->orderMetadata->markPaymentAsBlocks($order, "no"); + } + $this->transaction = new CreditsTransaction($this, $order); $this->mercadopago->logs->file->info('Customer being redirected to Mercado Pago.', self::LOG_SOURCE); diff --git a/src/Gateways/CustomGateway.php b/src/Gateways/CustomGateway.php index 29388f7bb..7fc00f8af 100644 --- a/src/Gateways/CustomGateway.php +++ b/src/Gateways/CustomGateway.php @@ -378,9 +378,11 @@ public function process_payment($order_id): array if (isset($_POST['mercadopago_custom'])) { $checkout = Form::sanitizeFromData($_POST['mercadopago_custom']); + $this->mercadopago->orderMetadata->markPaymentAsBlocks($order, "no"); } else { // Blocks data arrives in a different way $checkout = $this->processBlocksCheckoutData('mercadopago_custom', Form::sanitizeFromData($_POST)); + $this->mercadopago->orderMetadata->markPaymentAsBlocks($order, "yes"); } parent::process_payment($order_id); diff --git a/src/Gateways/PixGateway.php b/src/Gateways/PixGateway.php index 2af871a0a..62bda2301 100644 --- a/src/Gateways/PixGateway.php +++ b/src/Gateways/PixGateway.php @@ -175,9 +175,14 @@ public function process_payment($order_id): array $order = wc_get_order($order_id); try { parent::process_payment($order_id); - $checkout = Form::sanitizeFromData($_POST); + if (isset($_POST['wc-woo-mercado-pago-pix-new-payment-method'])) { + $this->mercadopago->orderMetadata->markPaymentAsBlocks($order, "yes"); + } else { + $this->mercadopago->orderMetadata->markPaymentAsBlocks($order, "no"); + } + if (!filter_var($order->get_billing_email(), FILTER_VALIDATE_EMAIL)) { return $this->processReturnFail( new \Exception('Email not valid on ' . __METHOD__), diff --git a/src/Gateways/TicketGateway.php b/src/Gateways/TicketGateway.php index 5e61eaf7c..95003e3c4 100644 --- a/src/Gateways/TicketGateway.php +++ b/src/Gateways/TicketGateway.php @@ -278,14 +278,18 @@ public function getPaymentFieldsParams(): array public function process_payment($order_id): array { $order = wc_get_order($order_id); + $checkout = []; try { parent::process_payment($order_id); - $checkout = Form::sanitizeFromData($_POST['mercadopago_ticket']); - // Blocks data arrives in a different way - if (empty($checkout)) { + if (isset($_POST['mercadopago_ticket'])) { + $checkout = Form::sanitizeFromData($_POST['mercadopago_ticket']); + $this->mercadopago->orderMetadata->markPaymentAsBlocks($order, "no"); + } else { + // Blocks data arrives in a different way $checkout = $this->processBlocksCheckoutData('mercadopago_ticket', Form::sanitizeFromData($_POST)); + $this->mercadopago->orderMetadata->markPaymentAsBlocks($order, "yes"); } if (