Problem/Motivation
If paypal returns the pending state, the order is not completed. Only tested with a review step using smart buttons.
The pending state is set, fe. when the currency of the payment is not defined in the sellers paypal profile.
In this case the seller still can accept the payment and choose what to do with the new currency at paypal.com
Proposed resolution
As it's strange for the user to stay on the review step, we should show an error message and map the remote pending state in some cases according to the status_details (see authorization->status_details here https://developer.paypal.com/docs/api/orders/v2/) to authorization or completed.
It even may be that manual review is the only reason (according to the api docs linked above):
The reason why the authorized status is PENDING. The possible values are:
PENDING_REVIEW. Authorization is pending manual review.Other reasons for the pending state out of the paypal universe, not sure if they apply to the new SDK:
Address: the attendee did not include a confirmed shipping address, and your Payment Receiving Preferences calls for you to manually accept these payments. You can change this in the Preferences section of your Profile.
Authorization: payment requires manual authorization.
eCheck: the eCheck has not yet cleared. Most eChecks take 5-7 days to clear.
International: your Paypal account is outside the US and you do not have a withdrawal process, which means you have to manually accept the payment in your Account Overview.
Order: the payment action has been set to order and hasn’t been accepted.
Payment Review: Paypal is manually reviewing the payment, most likely due to possible risk or fraud.
Regulatory Review: Paypal is manually reviewing the payment, due to government compliance and regulations. Usually cleared within 3 business days.
Unilateral: the attendee's email address has not been confirmed.
Upgrade: you must upgrade your account to Business or Premier before you can receive the funds, or you have reached the monthly transaction limit.
Verify: your account has not been verified. Check your email (associated with the Paypal account) to complete the verification process.Taken from here https://help.ticketbud.com/hc/en-us/articles/216669337-Why-are-my-incomi...
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3143995-handle_pending_payments-6.patch | 1.32 KB | ytsurk |
Comments
Comment #2
ytsurkComment #3
ytsurkComment #4
ytsurkComment #5
ytsurkComment #6
ytsurkHere some code too :D
Comment #7
ytsurkComment #8
ytsurkComment #9
jsacksick commentedI'm not sure about:
when the payment needs review (perhaps we should make a setting for that? Otherwise that means we'll allow the order to go through?
Comment #11
jsacksick commentedI gave your patch a second though, tweaked it a bit and committed it! Thanks!
Comment #13
Peter Buchanan commentedWhen a PayPal account hasn't been used for some time and then gets a run of payments PayPal takes the money and puts payments into a suspend state for a few days. For a high end fashion business the pandemic has seen customers not using shops and buying online.
Commerce doesn't get a notification that the payment is received and leaves the transaction in the cart. The user and the PayPal admin get a notification that the payment has been made.
I'd like to be able to treat the message as transaction complete with, ideally, a warning to the shop manager. I'd also like the client to receive the completion email.
This must be a reasonably common event and Drupal Commerce should be able to handle it.