Adyen In-person Payment Loyalty Integration Demo
This demo shows developers how to implement a loyalty flow using the Adyen Cloud Terminal API. This is done using Card Acquisition, and enables you to sign-up a shopper to a loyalty program or check cardholder details before applying discounts. We describe two flows:
- One where the shopper wants to buy a pizza and wants to sign-up to your loyalty program - This is known as a card acquisition request followed by a payment.
- One where the shopper only wants to sign-up to your loyalty program - This is known as a card acquisition request followed by a cancellation.
There are typically two ways to integrate in-person payments: local or cloud communications. To find out which solution (or hybrid) suits your needs, visit the following documentation page.
This demo leverages Adyen's API Library for .NET (GitHub | Docs). You can find the Terminal API documentation here.
- A terminal device and a test card from Adyen
- An Adyen account, learn how an Adyen account is structured in our documentation
- .NET Core SDK 6.0+
git clone https://github.com/adyen-examples/adyen-dotnet-online-payments.git
- Adyen API Key
- Adyen HMAC Key
ADYEN_POS_POI_ID
: the unique ID of your payment terminal for the NEXO Sale to POI protocol.- Format:
[device model]-[serial number]
Example:V400m-123456789
- Format:
On Linux/Mac/Windows export/set the environment variables.
export ADYEN_API_KEY=yourAdyenApiKey
export ADYEN_HMAC_KEY=yourHmacKey
export ADYEN_POS_POI_ID=v400m-123456789
Alternatively, it's possible to define the variables in the appsettings.Development.json
.
{
"ADYEN_API_KEY": "yourAdyenApiKey",
"ADYEN_HMAC_KEY": "yourHmacKey",
"ADYEN_POS_POI_ID": "v400m-123456789"
}
dotnet run --project in-person-payments-loyalty-example
- Buy a pizza by clicking 'Pay', which sends a card acquisition request
- Present your card on the terminal
- Terminal asks the shopper whether they want to sign-up for a loyalty program (collect +100 points on every purchase, and get a discount after 200 points).
- The terminal then asks the shopper to either:
- Finish the the request with a payment: shopper pays and is signed up for the loyalty program if they consent.
- Finish the request with a cancellation request: shopper only signs up for the loyalty program (without making a payment).
- When a shopper returns, they can click the 'Apply discount'-button to get a discount if they have over 200 points.
Webhooks deliver asynchronous notifications about the payment status and other events that are important to receive and process. You can find more information about webhooks in this blog post.
In the Customer Area under the Developers → Webhooks
section, create a new Standard webhook
.
A good practice is to set up basic authentication, copy the generated HMAC Key and set it as an environment variable. The application will use this to verify the HMAC signatures.
Make sure the webhook is enabled, so it can receive notifications.
This demo provides a simple webhook implementation exposed at /api/webhooks/notifications
that shows you how to receive, validate and consume the webhook payload.
The following webhooks events
should be enabled:
- AUTHORISATION
To make sure that the Adyen platform can reach your application, we have written a Webhooks Testing Guide that explores several options on how you can easily achieve this (e.g. running on localhost or cloud).