Payment failed on order pay page
-
No such PaymentMethod: ‘pm_xxxxxxxx’. Payment method error for the admin.
I’m using two stripe accounts for the payment page. I’m switching the stripe keys based on different countries to get the payment in different stripe accounts at the time of payment. On the order pay page, when I’m trying to make the payment, it is giving me this error. Here is the code for that. I’m using this filter “wc_stripe_get_secret_key” for updating the payment method, billing country, and card type.
my below code works fine and It is working fine on the woocommerce checkout page but it is not working on the order pay page, and getting the same error again and again.add_filter('wc_stripe_get_secret_key', 'change_stripe_secret_key', 10, 2);
function change_stripe_secret_key($secret_key, $mode) {
if (is_checkout() || is_wc_endpoint_url('order-pay')) {
global $woocommerce;
$logger = wc_get_logger();
$context = array('source' => 'change_stripe_secret_key');
$chosen_payment_method = $woocommerce->session->get('chosen_payment_method');
$billing_country = $woocommerce->customer->get_billing_country();
$chosen_card_type = $woocommerce->session->get('chosen_card_type');
if ($chosen_payment_method === 'stripe_cc' && ($billing_country === 'AE' || $chosen_card_type === 'amex')) {
$new_secret_key = get_option('secret_key_sg');
if ($new_secret_key && $new_secret_key !== $secret_key) {
$secret_key = $new_secret_key;
// wc_add_notice(__('The Secret Key has been updated for this transaction.'), 'notice');
$logger->info('Stripe secret key updated .', $context);
}
}
}
return $secret_key;
}
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.