Search code examples
node.jsreactjsadyen

Adyen session needs to be created after order creation


I am working on a store where we need to integrate Adyen React drop-in components.

I have followed and integrated the guide from here: https://docs.adyen.com/online-payments/web-drop-in

So the workflow that we need to implement is the following:

  1. User adds products to cart
  2. User checkouts and is redirected to checkout page
  3. User adds billing details as well as payment details (card details)
  4. After validation of data, user clicks "Pay"
  5. Order is created
  6. If payment was OK, then order is moved to confirmed status
  7. Else, if payment was refused, order is moved to awaiting payment status.

But right now the integration with Adyen forces us to the following steps:

  1. User adds products to cart
  2. User checks out and is redirected to checkout page
  3. User adds billing details
  4. Adyen session is initiated (with 'reference' to an order ID which is not created at this time), so that the payment details can be filled with user data
  5. User adds payment details ....rest

When creating an Adyen SESSION, it is mandatory to provide a reference, and this reference will be the link between an order and a payment. From the above workflows, you can see that we are forced to have an order ID as soon as the user fills payment data and we don't want that.

We want to create the order only at the end of transaction.

Is it possible to achieve this?

I have tried following the React and NodeJS guides available on git repository but they are just generating a random UUID for every payment


Solution

  • Unfortunately it is not possible to modify the payment reference after creating the session.
    The only way around would be to re-create a new session (using the OrderId) but still before performing the payment.