Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WooCommerce orders left in “Pending Payment” after a decline #222

Merged
merged 3 commits into from
Aug 13, 2021

Conversation

Dinamiko
Copy link
Contributor

@Dinamiko Dinamiko commented Aug 11, 2021

Description

WooCommerce orders left in “Pending Payment” after a decline.

Steps to test:

Use this filter to return a INSTRUMENT_DECLINED error in the response.

add_filter('ppcp_request_args', function ($args, $url){
    if (strpos($url,'capture') !== false) {
        $args['headers']['PayPal-Mock-Response'] = '{"mock_application_codes": "INSTRUMENT_DECLINED"}';
    }
    return $args;
}, 10, 2);

Changelog entry

WooCommerce orders left in “Pending Payment” after a decline. #222

@Dinamiko Dinamiko changed the title Update order status to failed when instrument is declined Payments left in “Pending Payment” after a decline. Aug 11, 2021
@Dinamiko Dinamiko changed the title Payments left in “Pending Payment” after a decline. Payments left in “Pending Payment” after a decline Aug 11, 2021
@Dinamiko Dinamiko changed the title Payments left in “Pending Payment” after a decline WooCommerce orders left in “Pending Payment” after a decline Aug 11, 2021
@Dinamiko Dinamiko requested a review from strangerkir August 11, 2021 13:38
Copy link
Contributor

@strangerkir strangerkir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok, but I have a few questions to be absolutely sure.

'failed',
__( 'Instrument declined.', 'woocommerce-paypal-payments' )
);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work, but I have some doubts about it.
The code below gives 3 tries, from what I can see, before suggesting the customer using another payment method. Does it make sense if the order is already marked as failed?
Another thing I'm not sure about is why it checks for the INSTRUMENT_DECLINED only? I know, it's out of the scope of this PR, but just want to make sure there will be no problems with it. It looks like the order will be marked as failed only in case of this error 🤔 Is it the expected result?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @strangerkir thanks for the feedback,

Regarding retrying, if payment is accepted on second or third try order status changes from failed to on-hold first and then to processing, I´ve checked and it works like so now.

About the INSTRUMENT_DECLINED only, I have just added failed order status to the other two failing cases, thanks for the hint :)

@Dinamiko Dinamiko merged commit ef1357a into trunk Aug 13, 2021
@Dinamiko Dinamiko deleted the PCP-220-payments-left-in-pending-paymen branch August 13, 2021 12:43
@Dinamiko Dinamiko mentioned this pull request Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants