Updating shipping options via backend callback endpoint
If you use the Dintero Web SDK and provide an
onAddressCallback function, the checkout does not call express.shipping_address_callback_url. See Updating shipping options via frontend callback function.session.express.shipping_address_callback_url with an updated order including the new address.
The webshop should update the webshop state/order with the new shipping address, and return a list of available shipping options for the given shipping address.
Link to the API specification for the callback endpoint. Note that the request body is what Dintero will post to your endpoint and the response is what your endpoint returns back to Dintero.
If the checkout is embedded, the Dintero Web SDK will call onSession whenever the session is updated, with the
event SessionUpdated.
Compatibility with “one click” Apple Pay and Google Pay
In order to support one click express payments via Apple Pay and Google Pay your endpoint must support returning shipping options when thesession.order.shipping_address in the request body from Dintero’s systems contains only country and postal_code.
Troubleshooting the backend callback
If correction item is added to the order
If the implementation has problems with items of the type correction, you might have problems with the shipping address callback.Item with correction
order.amount.
To solve this, make sure that order.amount contains the amount from the shipping option which is currently chosen.
Example
If the callback contains the following:10000 from the
request order.shipping_option.amount:
Updating shipping options via frontend callback function
This only applies when the checkout is embedded and the embedding site is using the Dintero Web SDK. It is not available when the checkout is opened withredirect(). In pop-out mode the embedding page handles the callback, not the pop-out window.
If the onAddressCallback function is provided, the checkout will not perform the machine to machine address update callback defined in the session at express.shipping_address_callback_url. Instead the SDK runtime has to handle the address update flow.
The onAddressCallback function is invoked when an end user submits their address details (the shipping and billing addresses) in an embedded Checkout Express session. The callback function is invoked with an updated session that is not yet persisted in the Dintero backend. The checkout will be locked and payment will be paused until the provided callback function is called, or checkout.submitAddressCallbackResult is called with the result.
The function receives an event with the event type, the updated session, and the callback used to return the result.
When onAddressCallback is invoked you will have to perform a server-to-server session update with shipping options or other details that have changed. Once the session has been updated you need to call the provided callback function with a result.
When the session has been updated successfully, return a successful result:
When implementing the
onAddressCallback, there is no need to manually lock the session and refresh it as described in Updating a checkout session. The checkout will automatically lock the payment and refresh the session when the callback function is used to return a result.onAddressCallback function throws, the SDK returns { success: false, error: "Address callback runtime error" } on your behalf so the checkout is not left waiting.
See also the onAddressCallback section in the Dintero Web SDK documentation.