Implementation examples
.NET
With Adyen, you can set up a loyalty program where shoppers do not need to have a physical loyalty card. Instead, you identify shoppers based on payment data that you receive in card acquisition and payment responses.
If you recognize a shopper based on the payment data, you can offer tailored benefits like discounts, or make product recommendations based on their purchase history. If you do not recognize a shopper, you can enroll them on the spot using the payment terminal.
To use this method, you need to create customer profiles in your back-end system. A customer profile should contain the payment data that you use to identify the shopper, together with any other details that your use case requires, such as purchase history data.
For instructions, select the payment data that you want to use for identifying shoppers:
Card and shopper identifiers
You can use the card alias to recognize the shopper's card. But you can also go one step further and create your own identifiers to be returned in card acquisition and payment responses. That enables you to identify an individual, not just their payment card, and make the shopping experience more personal.
To be able to personalize the shopper experience, save the following identifiers:
- Card alias (
alias
): a value that uniquely represents the shopper's card number (PAN), for exampleA37317672402294
. With this, you can recognize the card that a shopper is using. You cannot use the card alias for making payments. You receive the card alias in theAdditionalResponse
. - Shopper reference (
shopperReference
): this is your reference to identify the shopper. You submit it with a payment, and receive it back in theAdditionalResponse
for that payment and also for any later card acquisition and payment responses.To get the shopper reference, you need to enable receiving this identifier.
- Shopper email (
shopperEmail
): you collect the shopper's email address in some way, and submit it with a payment. You receive it back in theAdditionalResponse
for that payment and also for any later card acquisition and payment responses.
Shopper consent and PIN entry
To save a shopper profile in your back-end system and to save the shopper reference and email on our platform, you need to ask the shopper for their consent.
We only save the shopper reference and email if your initial request also contains the recurringContract flag. This flag triggers the terminal to ask the shopper to authenticate by entering their PIN. Because there are still cards being used that do not have a PIN, our Support Team can disable asking for a PIN when the recurringContract flag is set. However, it goes against best practices to set this flag for every transaction.
Requirements
- Enable receiving shopper identifiers.
- Ask our Support Team to check that your account is correctly configured for your loyalty use case.
Synchronous flow
The synchronous flow allows you to actively engage the shopper on the spot. For example, if you recognize the shopper from a card acquisition, you can apply a discount or offer to redeem loyalty points before making the payment.
- Make a card acquisition request to check whether the shopper is recognized.
- If the card acquisition response indicates the shopper isn't known yet, create a new customer profile and make a payment. To ask the shopper's consent and gather the data for the customer profile, you can make input requests.
- If the card acquisition response indicates the shopper is already known, optionally make input request to communicate with the shopper, and then make a payment for a recognized shopper.
Check whether the shopper is recognized
When the shopper makes a purchase, first check if you already know the shopper. If you are in Estonia, choose the Estonian ID card check tab below to learn how to identify the shopper with their national ID card.
Create a new customer profile and make a payment
When the card acquisition response shows the shopper isn't known yet, you continue with a payment request that:
- Refers to the card acquisition request.
- Creates shopper identifiers to save in your back end system.
-
Collect details from the shopper (depending on your use case), and ask the shopper's consent to save their details.
You can let your staff enter the information in your POS app, but you can also make input requests to collect the information on the terminal. For example:- Make a confirmation input request or a signature input request to ask the shopper's consent.
- Make text input requests to collect the shopper's name and email address, and a digit input request to collect their phone number.
- Make a display request with a QR code containing a URL to join your loyalty program or to download an app.
-
Make a
PaymentRequest
with:Parameter Required Description SaleData.TokenRequestedType
Customer. Returns the card alias in the TokenValue
field of the response. Note that the card alias is always returned in theAdditionalResponse
.PaymentData.CardAcquisitionReference
An object referencing the card acquisition: TimeStamp
: The time stamp returned in thePOIData.POITransactionID
of the card acquisition response.TransactionID
: The transaction ID returned in thePOIData.POITransactionID
of the card acquisition response.
SaleData.SaleToAcquirerData
Data to create shopper identifiers. See the instructions below.
In
SaleData.SaleToAcquirerData
include:
shopperReference
: your unique reference for this shopper. Minimum length: three characters. Note that the value is case-sensitive. Do not include personally identifiable information (PII), such as name or email address.shopperEmail
: optional. The shopper's email address, if you collected that in the first step.recurringContract
: ONECLICK. This triggers us to store the shopper reference and email on our platform.
Pass the
SaleToAcquirerData
value in one of the following formats:- Option 1: a JSON object converted to a Base64 encoded string. Refer to Add information to a payment.
- Option 2: form-encoded key-value pairs (using & as a separator). For example:
shopperReference=12345&shopperEmail=S.Hopper@example.com&recurringContract=ONECLICK
The format that you use here, will also be the format of the
AdditionalResponse
that you receive. -
When you receive the response, keep the following identifiers from the
AdditionalResponse
(you may need to Base64-decode the string first):alias
: the card alias.
If you specified aTokenRequestedType
of Customer in the request, the card alias is also returned inPaymentToken.TokenValue
.PaymentAccountReference
: a value that represents the shopper's payment account that their card and/or NFC wallet is linked to. For NFC wallet transactions, a PAN is not available and thus there's no card alias.shopperReference
: your unique reference for this shopper that you specified in the request.shopperEmail
: the shopper's email address that you specified in the request.
The identifiers for this shopper are now stored on the Adyen payments platform.
-
In your system, create a customer profile for the shopper and save the shopper identifiers that you received in the payment response.
-
Also save the transaction data with the shopper's customer profile, to start building a transaction history.
Make a payment for a recognized shopper
When the card acquisition response shows the shopper is known already, you follow up with a payment request that refers to the card acquisition.
-
Using the
shopperReference
or other identifiers you received in the card acquisition response, find the shopper in your system. -
Depending on your business logic, you may want to apply a discount, or offer a gift. For example:
- Make a confirmation input request to ask whether the shopper wants to redeem loyalty points.
-
Make a display request with a QR code containing a link to a promotional offer.
-
If necessary, update the final transaction amount. For example, if you applied a discount.
-
Make a
PaymentRequest
with:Parameter Required Description SaleData.TokenRequestedType
Customer. Returns the card alias in the TokenValue
field of the response. Note that the card alias is always returned in theAdditionalResponse
.PaymentTransaction.AmountsReq
An object with: Currency
: The transaction currency.RequestedAmount
: The final transaction amount.
PaymentData.CardAcquisitionReference
An object containing data from the card acquisition: TimeStamp
: The time stamp returned in thePOIData.POITransactionID
of the card acquisition response.TransactionID
: The transaction ID returned in thePOIData.POITransactionID
of the card acquisition response.
-
When you receive the response, keep the following identifiers from the
AdditionalResponse
(you may need to Base64-decode the string first):alias
: the card alias.
If you specified aTokenRequestedType
of Customer in the request, the card alias is also returned inPaymentToken.TokenValue
.PaymentAccountReference
: a value that represents the shopper's payment account that their card and/or NFC wallet is linked to.shopperReference
: your unique reference for this shopper, if you specified that when you created the customer profile.shopperEmail
: the shopper's email address, if you specified that when you created the customer profile.
-
In your system, store the transaction data with the shopper's customer profile.
Asynchronous flow
The asynchronous flow is a simpler implementation of shopper loyalty, where you rely on webhooks to make loyalty adjustments in your system after the payment. In this flow, you cannot apply discounts or other loyalty benefits on the spot before the payment.
- Make sure that you have set up receiving standard webhooks.
- Create a customer profile for the shopper in your loyalty system.
- Make a payment.
- Wait for the AUTHORISATION webhook.
- Based on the identifiers in the AUTHORISATION webhook, update the shopper's customer profile in your loyalty system. For example, add loyalty points.
- Inform the shopper of the update in your loyalty system.
For more information about this flow, see our omnichannel documentation.