In the createDropin() method's configuration object, set the redirectobject'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 onSuccesscontains a source whose state is pending_redirect. When you receive this event, retrieve source.id from data.
letdigitalRiver=newDigitalRiver("Your public API key",{"locale":"en-GB"});letconfiguration={"sessionId":"fe50c56f-88a4-4961-8142-7d4784b87264","options":{"flow":"checkout","redirect":{"disableAutomaticRedirects":true,"returnUrl":"https://mywebsite.com/paymentCallBack.html","cancelUrl":"https://mywebsite.com/paymentCallBack.html"},...},onSuccess:function(data){ //send sourceId to your backendvarsourceId=data.source.id;},...}letdropin=digitalriverpayments.createDropin(configuration);dropin.mount("drop-in");
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:
At this point, retrieve the cart 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 checkout'sid to your server and sending it in the body of a create order request.
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.
If the order's state is pending_payment and the payment.session.state is pending_funds, refer to the Delayed payment flow section.
Once customers complete either of these actions, they're redirected to the endpoint you assigned to cancelUrl and/or returnUrl.
When this resource loads, call a function that initiates a server-side request and sends the order's identifier and refresh in the path.
If (1) state is accepted or in_review or (2) state is pending_payment and payment.session.state is pending or pending_funds, then a charges[] on the sources[] whose flow is redirect has been successfully authorized, and you should display an order confirmation page and send a confirmation email.
Any other (1) state value or (2) combination of state and payment.session.state values indicate that the order can't be recovered. As a result, you'll need to recreate the checkout and send customers back to the payment collection stage. For details, refer to Handling rejected orders.