Support » Plugin: Stripe For WooCommerce » Local Gateway Payment getting error payment intent after payment completed

  • Resolved isaac2017

    (@isaac2017)


    Hi Clayton,

    I have been getting a particular bug from my local payment gateway which is giving me a lot of headache. It does not happen everytime but 1 – 4 times a day.

    The error I get from stripe is this
    “Error processing payment. Reason: This PaymentIntent’s payment_method_types could not be updated because it has a status of succeeded. You may only update the payment_method_types of a PaymentIntent with one of the following statuses: requires_payment_method, requires_confirmation, requires_action. Order status changed from Paid to Failed.”

    I am getting this error at the same instant as the payment is being processed. I believe this call (could be chargeable or succeeded) is returning with a successful status but with an error message. But I can’t seem to find the area to catch this exception.

    Can you point me to the right direction to check?

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author mr.clayton

    (@mrclayton)

    Hi @isaac2017,

    Have you written any custom code on your site that’s hooking in to the plugin’s filters or expanding the plugin’s base functionality? There is only one area in the plugin where the payment_method_types array is added to the payment intent object.

    https://docs.paymentplugins.com/wc-stripe/api/source-class-WC_Stripe_Payment_Intent.html#213

    The payment_method_types is included in the payment_intent update call if the payment_intent’s calculated hash is not equal to the calculated hash of the intent that’s serialized in the order’s metadata. However, there isn’t anywhere in the plugin where a payment_intent with a status of success would be updated because the only entry point for that is the process_payment function of the gateway class.

    Kind Regards,

    Hi Clayton,

    I have not added any new filters for the based plugin functionality, so the payment intent methods is currently in its default state.

    Thanks for the process_payment pointer. I added an action at “wc_stripe_before_process_payment” to check if the order status is completed and added wc_add_notice so that the payment process would he halted.

    Am not sure if this hack would work, will be monitoring the outcome through the day.

    Thanks for your help.

    Plugin Author mr.clayton

    (@mrclayton)

    Is this occurring on the checkout page or during a webhook? There isn’t anything in the plugin that should allow that process to be called when the intent’s status is succeeded.

    Hi Clayton,

    So this happens for both redirect and webhooks.

    I have made some progress in the debugging of the isses.
    The normal scenario based on the log is as such.

    1. Customer clicks on checkout in the checkout page.
    2. Gets redirected to bank for further processing.
    4. After customer has filled in required security info, bank start processing.
    5. webhook.charge_succeeded is received.
    6. webhook.paymentintent_succeeded is received.
    7. redirect to order received page.
    8. payment_method->process_payment is executed.
    9. Order is now completed.

    Now the problem arises here. The webhooks did not manage to get back to the server and during the payment_method->process_payment execution, stripe returns the with the error message that the payment intent is no longer valid because the order has already been charged and paid for in stripe.

    I am thinking is there a way to use the payment_intent payload which is returned with the result to process the payment information properly.
    eg. $result[‘error_data’][‘payment_intent_error’][‘payment_intent’]

    What do you think?

    Plugin Author mr.clayton

    (@mrclayton)

    Hi @isaac2017,

    Thank you for your detailed response. Can you contact me via the support email (Help button on all Stripe plugin pages)? I want to send you a code suggestion to see if it makes any difference in the behavior you are seeing.

    I will update this thread once you and I speak via the support channel.

    Kind Regards,

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.