Handling redirect payment methods
Gain a better understanding of how to handle transactions funded with a redirect payment method
Last updated
Was this helpful?
Gain a better understanding of how to handle transactions funded with a redirect payment method
Last updated
Was this helpful?
If you're using and customers opt to fund a transaction with a , such as , , and , whose resulting has a of redirect
must be redirected to the payment provider, where they either approve or cancel the funds transfer.
We recommend and then redirecting the customer to do this.
On this page, you find:
In the method's , set the object's disableAutomaticRedirects
to true
and assign the same value to both returnUrl
and cancelUrl
.
If customers select a redirect payment method, the data
returned by contains a whose is pending_redirect
. When you receive this event, retrieve source.id
from data
.
This operation moves the source into "pending redirect" state, the order state to "Source pending redirect", and provides you with the redirectUrl
to present to the customer:
If its value is pending_redirect
, and payment.session.nextAction.data.redirectUrl
is a non-null value, then redirect customers to this third-party provider's interface URL, where they can either approve or cancel payment.
Once customers complete either of these actions, they're redirected to the endpoint you assigned to cancelUrl
and/or returnUrl
.
Next, pass this identifier in a server-side .
At this point, retrieve the data you need—such as currency
, orderTotal
, subTotal
, tax
, billingAddress
, shippingAddress
,payment.sources[]
, and relevant lineItems
—to build a review page.
If, after reviewing the transaction's details, customers click your submit order button, handle that event by passing the id
to your server and sending it in the body of a .
If you get back a 201 Created
, and the is pending_payment
, then check .
If the order's state
is pending_payment
and the payment.session.state
is pending_funds
, refer to the section.
When this resource loads, call a function that initiates a server-side request and sends the identifier and refresh
in the path.
If you get a 200 OK
, check the order's and .
If (1) is accepted
or in_review
or (2) state
is pending_payment
and is pending
or pending_funds
, then a on the whose is redirect
has been successfully authorized, and you should display an order confirmation page and send a.
At this point, you can initiate .
Any other (1) value or (2) combination of state
and values indicate that the can't be recovered. As a result, you'll need to recreate the and send customers back to the payment collection stage. For details, refer to .