In the createDropin() method's configuration object, set the redirect 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 onSuccess contains a source whose state is pending_redirect. When you receive this event, retrieve source.id from data.
let digitalRiver =newDigitalRiver("Your public API key", {"locale":"en-GB"});let configuration = {"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 backendvar sourceId =data.source.id; },...}let dropin =digitalriverpayments.createDropin(configuration);dropin.mount("drop-in");
At this point, retrieve the checkout data you need—such as currency, totalAmount, subTotal, totalTax, shipTo, shippingChoice,payment.sources[], and relevant items[].productDetails—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 to this url, which is the third-party provider's interface, where customers either approve or cancel payment.
If the order's state is pending_payment and the payment.session.state is pending_funds, refer to Handling delayed payment methods.
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 send the order's identifier and refresh in the path.
curl --location --request POST 'https://api.digitalriver.com/orders/240354510336/refresh' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <Secret API key>' \
...
--data-raw ''
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 indicates 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.