You can add configuration to your payment server for additional functionality.
- Update the payment amount of the session
- Get the result of the payment session on your payment server
Update the payment amount of the session
After you create a session, the order amount can change before the shopper submits the payment. For example, the shopper may add or remove items from their cart, or a discount may apply. You can update the session with the new amount so that the shopper pays the correct total.
Create a session
To enable updating the payment amount of a session, you must indicate it when you create the session.
-
When you create a session, additionally include:
Parameter Required Description payableIndicates if the session is ready for the shopper to submit the payment.
Set to false: Indicates that the session is not yet ready for the shopper to submit the payment, so the payment amount can be updated. -
Confirm that the response includes
payable: false.
Update the session amount
To update the payment amount, make a PATCH /sessions/{sessionId} request, including:
| Parameter | Required | Description |
|---|---|---|
sessionId Path parameter |
The ID of the session to update. | |
sessionData |
The encoded session data from the original /sessions response. | |
amount.value |
The updated amount in minor units. | |
amount.currency |
The three-character ISO currency code. | |
payable |
If you know that the amount in this request is the final amount, set to true. This indicates that the session is ready for payment. When you set this to true, you can no longer update the session. If you set to false, you must make another request to update the session and set to true before the shopper can submit the payment. |
After you set payable to true, you cannot update the session again. Only set this when you confirm the final amount, and the session is ready for payment.
The response includes the updated session data.
Update the amount in Drop-in
Update the amount in Drop-in when the payment amount changes (for example, when the shopper adds or removes items from their cart). The amount can be updated multiple times without the need to update the server-side session data every time. The server-side session update is required only before the shopper can submit the payment.
Show the updated amount to the shopper
To show the updated amount in the payment form:
From your instance of AdyenCheckout, call the update function and pass the new amount.
Update the server-side session data before payment
When you confirm the final amount, you must update the server-side session data with the amount before the shopper submits the payment.
- Trigger the
beforeSubmitcallback from your instance ofAdyenCheckoutto make a PATCH/sessions/{sessionId}request to update the session from your server. -
The session patching request returns an updated
sessionDataobject. Add it to theactions.resolvemethod, to pass it to Drop-in.When you make a request to update the server-side session data, you must store and get the updated amount on your server. Do not get the updated amount from the client.
Get the result of the payment session on your payment server
Instead of only getting the payment result in a webhook message, you can also get the result of the payment session on your payment server.
- Get the
idfrom the/sessionsresponse. - Get
sessionResultfrom theonPaymentCompletedoronPaymentFailedevent. -
Make a GET
/sessions/{id}?sessionResult={sessionResult}request including theidandsessionResult. For example:The response includes the result of the payment session (
status). For example:The additionalData attributes in the response depend on the type of payment made.
Possible statuses:
statusDescription completed The shopper completed the payment. This means that the payment was authorized. paymentPending The shopper is in the process of making the payment. This applies to payment methods with an asynchronous flow. canceled The shopper canceled the payment. expired The session expired (default: 1 hour after session creation). Shoppers can no longer complete the payment with this sessionId.
The status included in the response doesn't get updated. Do not make the request again to check for payment status updates. Instead, check webhooks or the Transactions list in your Customer Area.