Default icon

Optional server configuration

Add optional configuration to your payment server.

View source

You can add configuration to your payment server for additional functionality.

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.

  1. When you create a session, additionally include:

    Parameter Required Description
    payable Required Indicates 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.
  2. 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
Required The ID of the session to update.
sessionData Required The encoded session data from the original /sessions response.
amount.value Required The updated amount in minor units.
amount.currency Required 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.

  1. Trigger the beforeSubmit callback from your instance of AdyenCheckout to make a PATCH /sessions/{sessionId} request to update the session from your server.
  2. The session patching request returns an updated sessionData object. Add it to the actions.resolve method, 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.

  1. Get the id from the /sessions response.
  2. Get sessionResult from the onPaymentCompleted or onPaymentFailed event.
  3. Make a GET /sessions/{id}?sessionResult={sessionResult} request including the id and sessionResult. 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:

    status Description
    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.

See also