Skip to content

Commit 48e2f07

Browse files
committed
Fix change payment method in my account
Use Verif as transaction type
1 parent caf01fb commit 48e2f07

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

includes/class-wc-monei-redirect-hooks.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ public function save_payment_token() {
9696
* In the redirect back (from add payment method), the payment could have been failed, the only way to check is the url $_GET['status']
9797
* We should remove the "Payment method successfully added." notice and add a 'Unable to add payment method to your account.' manually.
9898
*/
99+
$accepted_statuses = array( 'SUCCEEDED', 'AUTHORIZED' );
99100
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
100-
if ( is_add_payment_method_page() && ( ! isset( $_GET['status'] ) || 'SUCCEEDED' !== wc_clean( wp_unslash( $_GET['status'] ) ) ) ) {
101+
if ( is_add_payment_method_page() && ( ! isset( $_GET['status'] ) || ! in_array( wc_clean( wp_unslash( $_GET['status'] ) ), $accepted_statuses, true ) ) ) {
101102
wc_clear_notices();
102103
wc_add_notice( __( 'Unable to add payment method to your account.', 'woocommerce' ), 'error' );
103104
$error_message = filter_input( INPUT_GET, 'message', FILTER_CALLBACK, array( 'options' => 'sanitize_text_field' ) );

src/Gateways/Abstracts/WCMoneiPaymentGateway.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ abstract class WCMoneiPaymentGateway extends WC_Payment_Gateway {
2525

2626
const SALE_TRANSACTION_TYPE = 'SALE';
2727
const PRE_AUTH_TRANSACTION_TYPE = 'AUTH';
28+
const VERIFY_TRANSACTION_TYPE = 'VERIF';
2829

2930
/**
3031
* Is sandbox?

src/Gateways/PaymentMethods/WCGatewayMoneiCC.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace Monei\Gateways\PaymentMethods;
44

5+
use Exception;
56
use Monei\Gateways\Abstracts\WCMoneiPaymentGatewayComponent;
67
use Monei\Services\PaymentMethodsService;
78
use Monei\Templates\TemplateManager;
9+
use WC_Geolocation;
810
use WC_Monei_API;
911
use WC_Monei_IPN;
1012
use WC_Monei_Subscriptions_Trait;
@@ -235,7 +237,7 @@ protected function create_zero_eur_payload() {
235237
'completeUrl' => wc_get_endpoint_url( 'payment-methods' ),
236238
'cancelUrl' => wc_get_endpoint_url( 'payment-methods' ),
237239
'failUrl' => wc_get_endpoint_url( 'payment-methods' ),
238-
'transactionType' => self::SALE_TRANSACTION_TYPE,
240+
'transactionType' => self::VERIFY_TRANSACTION_TYPE,
239241
'sessionDetails' => array(
240242
'ip' => WC_Geolocation::get_ip_address(),
241243
'userAgent' => wc_get_user_agent(),

0 commit comments

Comments
 (0)