Adyen Checkout Adapter

Overview

Adyen Checkout adapter is a payment adapter for Adyen Checkout. Read more on Adyen docs Norce checkout is based on the Adyen Advanced flow. The Advanced flow integration guide can be found here https://docs.adyen.com/online-payments/build-your-integration/additional-use-cases/advanced-flow-integration/?platform=Web&integration=Drop-in&version=5.55.1

Environments

There are two environments that you can use.

Environment Address
Test https://checkout-adyen-adapter.test.norce.tech
Production https://checkout-adyen-adapter.norce.tech

Configuration

You start by adding a Norce checkout configuration for the Adyen Checkout adapter in Norce Checkout Admin.

Make sure you have your Api-Key, Client-Key, and Merchant Account available, and incorporate them into your Norce Adyen configuration.

Create payment

To get a list of available payment methods, you start by initializing a Adyen payment for an existing Norce order. This JSON response from this request serves as a passthrough from Adyen's paymentMethodsResponse, extended with necessary Norce information for the frontend Adyen integration.

restjson
Copy
Copied
POST /api/checkout/v1/{order_id}/payments
Copy
Copied
{
    "paymentId": "puuscBIDcQYUdLqobvYlXVANPBR",
    "clientKey": "your_test_key_from_adyen_set_in_configuration",
    "locale": "sv-SE",
    "environment": "test",
    "amount": {
        "currency": "SEK",
        "value": 12300
    },
    "paymentMethodsResponse": {
        "paymentMethods": [
            {
                "brands": [
                    "mc",
                    "visa"
                ],
                "inputDetails": [],
                "issuers": [],
                "name": "Cardpayment",
                "type": "scheme"
            },
            {
                "brands": [],
                "inputDetails": [],
                "issuers": [],
                "name": "Buy now, pay later",
                "type": "klarna"
            },
            {
                "brands": [],
                "inputDetails": [],
                "issuers": [],
                "name": "Trustly - Direct bank payment",
                "type": "trustly"
            },
            {
                "brands": [],
                "inputDetails": [],
                "issuers": [],
                "name": "PayPal",
                "type": "paypal"
            },
            {
                "brands": [],
                "inputDetails": [],
                "issuers": [],
                "name": "Swish",
                "type": "swish"
            },
            {
                "brands": [],
                "inputDetails": [],
                "issuers": [],
                "name": "Klarna Account",
                "type": "klarna_paynow"
            }
        ],
        "storedPaymentMethods": []
    },
    "paymentMethodsConfiguration": {}
}

This response includes the necessary parameters for your configuration object required in Step 2 - Add Drop-in to your payments form. https://docs.adyen.com/online-payments/build-your-integration/additional-use-cases/advanced-flow-integration/?platform=Web&integration=Drop-in&version=5.55.1#add-drop-in

The Adyen Checkout adapter will also update your Norce Checkout order with the Adyen Checkout payment details. The payments[].id property represents the Norce Checkout order payment identifier and the payments[].orderId represents the Norce Checkout order identifier. No session or order is generated in Adyen at this stage.

Copy
Copied
{
    //...
    "payments": [
    {
      "id": "puuscBIDcQYUdLqobvYlXVANPBR",
      "adapterId": "adyen_dropin_adapter",
      "name": "adyen_dropin_adapter",
      "merchant": "norce-checkout-demo",
      "channel": "adyen-b2c-sweden",
      "currency": "SEK",
      "type": "default",
      "orderId": "oJVtUCHO",
      "amount": 123,
      "upperLimitAmount": 2147483647,
      "state": "intent",
      "attributes": {},
      "actions": []
    }
  ],
    //...
}

Complete order using recurring token

Complete an order using a recurring payment token
This endpoint enables the completion of an order using a stored recurring payment token.
This service is specifically designed for Subscriptions—recurring transactions made at regular intervals for a product or service.
One-off payments, automatic top-ups, and other non-fixed schedule contracts are not supported.
For more information, see Adyen Tokenization Documentation.

Important: To use this endpoint, you must enable the necessary webhook in your Adyen account settings.
Failure to do so will result in the functionality not being available.
For instructions on setting up the webhook, please refer to Enabling the Webhook.

Copy
Copied
POST /api/checkout/v1/orders/{order_id}/payments/recurring/subscription/complete

Request Body

Copy
Copied
{
  "token": "J65XNM8BMWHGQER6",
  "shopperReference": "shopperreference@domain.io"
}

token (string): The token representing the recurring payment method.
shopperReference (string): Reference ID of the shopper who owns the payment token.

Responses
200 OK: Returns a detailed PaymentResponse indicating successful transaction completion.
400 Bad Request: Indicates invalid input or configuration errors.
404 Not Found: Occurs if the specified order ID does not exist.

Example Response

Copy
Copied
{
  "resultCode": "authorised",
  "additionalData": {
    "recurringProcessingModel": "Subscription"
  },
  "amount": {
    "currency": "SEK",
    "value": 37500
  },
  "merchantReference": "otFOhHrZ-pMDNyreMxsBuscibQzRbETZPrzn",
  "paymentMethod": {
    "brand": "visa",
    "type": "scheme"
  },
  "pspReference": "PRVH2F72K8KZG4V5"
}

Update payment

If your cart or basket changes, you must re-render the payment options, as some of them may be filtered out in Adyen depending on factors like the amount.

If you have already initialized Norce Checkout payment for this order, you can refresh the available Adyen payment options by executing the following request. The Adyen adapter will extract the latest items, customer details, and shipping information from the Norce order and map it to Adyen.

Copy
Copied
GET /api/v1/checkout/{order_id}/payments/{payment_id}

The response will follow the identical format as the initial create payment response.

Copy
Copied
{
    "paymentId": "puuscBIDcQYUdLqobvYlXVANPBR",
    "clientKey": "your_test_key_from_adyen_set_in_configuration",
    "locale": "sv-SE",
    "environment": "test",
    "amount": {
        "currency": "SEK",
        "value": 12300
    },
    "paymentMethodsResponse": {
        "paymentMethods": [
            {
                "brands": [
                    "mc",
                    "visa"
                ],
                "inputDetails": [],
                "issuers": [],
                "name": "Cardpayment",
                "type": "scheme"
            },
            {
                "brands": [],
                "inputDetails": [],
                "issuers": [],
                "name": "Buy now. Pay later.",
                "type": "klarna"
            },
            {
                "brands": [],
                "inputDetails": [],
                "issuers": [],
                "name": "Trustly - Direct bank payment",
                "type": "trustly"
            },
            {
                "brands": [],
                "inputDetails": [],
                "issuers": [],
                "name": "PayPal",
                "type": "paypal"
            },
            {
                "brands": [],
                "inputDetails": [],
                "issuers": [],
                "name": "Swish",
                "type": "swish"
            },
            {
                "brands": [],
                "inputDetails": [],
                "issuers": [],
                "name": "Klarna Account",
                "type": "klarna_paynow"
            }
        ],
        "storedPaymentMethods": []
    },
    "paymentMethodsConfiguration": {}
}

Update customer and shipping option

Should there be any modifications to the customer or shipping details in your Norce Checkout order, you must make corresponding adjustments to the Adyen payment. This is achieved by performing an "Update Payment" as detailed earlier. The Norce Adyen adapter is specifically configured to map customer and shipping information solely from Norce orders to Adyen, the reverse operation is not supported.

Confirm payment

When the shopper selects the Pay button and payment details are valid the onSubmit(state, dropin) event is called. The frontend event handler is required to initiate a request to the Norce Adyen adapter

Copy
Copied
POST /api/checkout/v1/orders/{order_id}/payments/{payment_id}/transaction

using the event data as the request body.

The Norce Checkout Adyen adapter will handle the mapping of the request and proceed to make a /payments request to the Adyen API.

The response will be a PaymentResponse, mirroring the one received from the Adyen API. It will also update the Norce order with new status and details about the payment.

If the response includes an action, it should be managed by dropin.handleAction(response.action);

See the the Adyen Drop-in documentation for further clarification and detailed information. https://docs.adyen.com/online-payments/build-your-integration/additional-use-cases/advanced-flow-integration/?platform=Web&integration=Drop-in&version=5.55.1#add-drop-in

If this request is successful and no action is required the order will be accepted/completed, and the frontend can redirect the user to the confirmation page.

Additional Details

Some of the payment methods require the shopper to performed additional action, you need to submit additional payment details to either complete the payment, or to check the payment result. This is done in the onAdditionalDetails(state, dropin) event handler.

The frontend event handler is required to forward the additional detals from the event in a request to the Norce Adyen adapter

Copy
Copied
POST /api/checkout/v1/orders/{order_id}/payments/{payment_id}/details

The Norce Adyen adapter will handle the mapping of the request and proceed to make a /payments/details request to the Adyen API.

The response will be a PaymentDetailsResponse, mirroring the one received from the Adyen API. It will also update the Norce order with new status and details about the payment.

If this request is successful and the resultCode in the PaymentDetailsResponse is "ok," the order will be accepted/completed, and the frontend can redirect the user to the confirmation page.

Copyright © Norce 2024. All right reserved.