---
title: "Recognizing customers"
description: "Identify your returning customers when they purchase in your online and physical stores."
url: "https://docs.adyen.com/unified-commerce/loyalty-program/recognize-customers"
source_url: "https://docs.adyen.com/unified-commerce/loyalty-program/recognize-customers.md"
canonical: "https://docs.adyen.com/unified-commerce/loyalty-program/recognize-customers"
last_modified: "2020-06-18T14:30:00+02:00"
language: "en"
---

# Recognizing customers

Identify your returning customers when they purchase in your online and physical stores.

[View source](/unified-commerce/loyalty-program/recognize-customers.md)

After you have [created a profile for a customer](/unified-commerce/loyalty-program/create-profiles), you will be able to use the data in their profile to recognize them the next time they purchase in any of your sales channels.

Here we'll show you how to use shopper identifiers received in API responses to recognize a returning customer [online](#recognize-returning-customers-online) or [in store](#recognize-returning-customers-in-store).

## Recognize returning customers online

Before making their online purchase, your customer will provide you with an email address. They do that, for example, when creating an account for your online store, or when using your guest checkout.

To recognize whether they are a returning customer, check if their contact details match a `shopperEmail` that you have [stored in your customer database](/unified-commerce/loyalty-program/create-profiles#store-customer-data).

* *If the email matches*, they are a returning customer.
* *If the email is not in your database*, you can [create a customer profile for them](/unified-commerce/loyalty-program/create-profiles#create-profile-from-online-payment).

### Showing a saved card in your online checkout

If the customer created an online store account and you have saved and tokenized their card details in a previous point-of-sale payment, you can then offer them a more frictionless online checkout experience by showing their saved card details.

To present a customer's saved card in your online checkout:

1. Using the customer's email address, fetch their `shopperReference` and `storedPaymentMethodId` from your customer database.

2. If you are using Drop-in or Components, you can also confirm if the customer has saved card details when you make a POST [/paymentMethods](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods) call. In this request, additionally include the `shopperReference`.

   The following example shows how to do this for a customer with a `shopperReference` of **ShopperID-A16729**:

   **Payment methods request**

   ```json
   {
      "merchantAccount": "YOUR_MERCHANT_ACCOUNT",
      "{hint:This is the unique customer reference in your db}shopperReference{/hint}": "ShopperID-A16729",
      "amount": {
         "currency": "EUR",
         "value": 1099
      }
   }
   ```

   You receive a response containing a list of available payment methods, including the customer's stored payment details. You can find the customer's stored card in the `storedPaymentMethods` array.

   The example below shows what this response would look like if this customer has a stored **visa** card. The `storedPaymentMethods.id` should match the `storedPaymentMethodId` that you stored for this customer in your database.

   **Payment methods response**

   ```json
   {
      "paymentMethods":[...],
       "storedPaymentMethods":[
          {
             "brand":"visa",
             "expiryMonth":"03",
             "expiryYear":"2030",
             "holderName":"John Smith",
             "{hint: This is the storedPaymentMethodId}id{/hint}":"7219687191761347",
             "lastFour":"1111",
             "name":"VISA",
             "supportedShopperInteractions":[
                "Ecommerce",
                "ContAuth"
             ],
             "type":"scheme"
          }
       ]
   }
   ```

3. Present your customer's saved card details, and show a CVC/CVV field to collect their card security code.

   * If you are using **Drop-in**, this integration supports showing saved card details by default. For presenting your customer's saved card details with [Components](/payment-methods/cards#how-do-you-want-to-integrate), refer to [Web](/payment-methods/cards/web-component#recurring-payments), [iOS](/payment-methods/cards/ios-component#recurring-payments), or [Android](/payment-methods/cards/android-component/#recurring-payments). Both Drop-in and Components integrations present the saved card details, and collect and encrypt your customer's card security code.

   * If you are using an [API-only integration](/payment-methods/cards/api-only), you need to build your own UI to show the stored card details and to collect your customer's card security code. You can either build a custom [card integration with encryption](/payment-methods/cards/custom-card-integration#recurring-payments), or submit [raw card data](/payment-methods/cards/raw-card-data#recurring-payments) if you are [fully PCI compliant](/development-resources/pci-dss-compliance-guide?tab=api_only_4).

4. If the customer chooses to pay with their saved card, continue with the payment by making a POST [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request. In this request, additionally include:

   * `shopperReference`: the customer's `shopperReference`, from your database.

   * `shopperInteraction`: set this to **ContAuth** to indicate that the customer is a returning customer.

   * `recurringProcessingModel`: set to **CardOnFile** to specify a one-off payment.

   * `paymentMethod`: an object that contains the customer's card details:

     * `storedPaymentMethodId`: the customer's tokenized card details.

     * `encryptedSecurityCode` or `cvc`: the customer's card security code sent either as encrypted data (returned from Drop-in, Components, or custom card integration) or as raw data (if you are fully PCI compliant).

   The following example shows how to make a payment for a customer with a `shopperReference` of **ShopperID-A16729**, and a `storedPaymentMethodId` of **7219687191761347**.

   **Online payment request**

   ```json
   {
      "amount":{
         "value":2000,
         "currency":"USD"
      },
      "paymentMethod":{
         "type": "scheme",
         "storedPaymentMethodId":"7219687191761347",
         "encryptedSecurityCode": "adyen_737x19daxH..."
      },
      "reference":"YOUR_ORDER_NUMBER",
      "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
      "returnUrl":"https://your-company.example.com/...",
      "shopperReference":"ShopperID-A16729",
      "shopperInteraction":"ContAuth",
      "recurringProcessingModel": "CardOnFile"
   }
   ```

   If the payment is successful you receive a `resultCode` of **Authorised**.

   **Online payment response**

   ```json
   {
      "pspReference": "881532984281546H",
      "resultCode": "Authorised"
   }
   ```

## Recognize returning customers in store

When a customer makes a purchase at the point of sale, you can check if they are a returning customer by making a *card acquisition* request.

Check if the card `alias` returned in the response matches a card alias that you have [stored in your customer database](/unified-commerce/loyalty-program/create-profiles#store-customer-data).

* *If the alias matches*, they are a returning customer.
* *If the alias is not in your database*, you can [create a customer profile for them](/unified-commerce/loyalty-program/create-profiles#create-profile-from-point-of-sale-payment).

Apart from the card alias, the card acquisition request returns the `shopperReference` if you have previously stored it on our platform. You can also use that data to check whether the customer is a returning customer.

To recognize a customer when they make a purchase at the point of sale:

1. Make a [card acquisition request](/point-of-sale/card-acquisition).

   The example below shows a card acquisition request for a customer who is making a **EUR 10.99** purchase.

   **Card acquisition request**

   ```json
   {
       "SaleToPOIRequest": {
           "MessageHeader":{
               "ProtocolVersion":"3.0",
               "MessageClass":"Service",
               "MessageCategory":"CardAcquisition",
               "MessageType":"Request",
               "SaleID":"POSSystemID12345",
               "ServiceID":"0207111104",
               "POIID":"V400m-324688179"
           },
           "CardAcquisitionRequest": {
               "SaleData": {
                   "SaleTransactionID": {
                       "TransactionID": "15890",
                       "TimeStamp": "2019-12-04T12:02:49.000Z"
                   },
               },
               "CardAcquisitionTransaction": {
                   "TotalAmount": 10.99
               }
           }
       }
   }
   ```

   You receive a response that includes an `AdditionalResponse` object, with a base64-encoded string that you need to decode to get a JSON object, or a string of form-encoded key-value pairs. In our examples, we use form-encoded key-value pairs.

   **Card acquisition response**

   ```json
   {
       "SaleToPOIResponse": {
           "CardAcquisitionResponse": {
               "POIData": {
                   "POITransactionID": {
                       "TimeStamp": "2019-12-04T12:02:49.000Z",
                       "TransactionID": "4rVu001575460969123"
                   },
                   "POIReconciliationID": "1000"
               },
               "SaleData": {
                   "SaleTransactionID": {
                       "TimeStamp": "2019-12-04T12:02:49.000Z",
                       "TransactionID": "15890"
                   }
               },
               "PaymentInstrumentData": {...},
               "Response": {
                   "Result": "Success",
                   "AdditionalResponse":"...alias=M469509594859802...shopperReference=ShopperID-A16729&recurringDetailReference=..."
               }
           },
           "MessageHeader": {...}
       }
   }
   ```

2. Use the card `alias` in the `AdditionalResponse` object to look up the customer in your customer database.\
   If you have previously stored the `shopperReference` with Adyen, this is also provided in this response.

   * If you have a customer profile with the same `alias`, they are a returning customer.

   * If you *do not* have a customer profile with the same `alias` the customer's card is not recognized. This usually means that the customer is new, and has not purchased with you before. However, they could also be a returning customer using a new card.

   To confirm, you can [collect their email address](/unified-commerce/loyalty-program/create-profiles#create-profile-from-point-of-sale-payment), then check whether this matches a `shopperEmail` stored in your customer database:

   * If the email matches a `shopperEmail` in your database, they are a returning customer. Ask them if they want to save their new card. If they do, tokenize their new card using their `shopperReference` from your database when you make a payment.

   * If the email is not your database, they are a new customer. Continue with the transaction, and [create a profile for this customer](/unified-commerce/loyalty-program/create-profiles#create-profile-from-point-of-sale-payment).

3. Continue with the transaction by [making a payment request from your POS app](/point-of-sale/card-acquisition#continue-with-payment), containing data returned in the card acquisition response.

   **Terminal API Request**

   ```json
   {
      "SaleToPOIRequest":{
         "MessageHeader":{
            "ProtocolVersion":"3.0",
            "MessageClass":"Service",
            "MessageCategory":"Payment",
            "MessageType":"Request",
            "ServiceID":"0207112304",
            "SaleID":"POSSystemID12345",
            "POIID":"V400m-324688179"
         },
         "PaymentRequest":{
            "SaleData":{
               "SaleTransactionID":{
                  "TransactionID":"15887",
                  "TimeStamp":"2019-12-04T12:02:49.000Z"
               },
               "SaleToAcquirerData":"shopperReference=ShopperID-A16729&shopperEmail=john.smith@example.com&recurringContract=UnscheduledCardOnFile"
            },
            "PaymentTransaction":{
               "AmountsReq":{
                  "Currency":"EUR",
                  "RequestedAmount":10.99
               }
            },
            "PaymentData": {
               "CardAcquisitionReference": {
                  "TransactionID":"4rVu001575460969123",
                  "TimeStamp":"2019-12-04T12:02:49.000Z"
               }
            }
         }
      }
   }
   ```

   If the request is successful, you receive a response containing:

   * `POIData.POITransactionID.TransactionID`: the transaction identifier for the payment.

   * `PaymentResponse.Response.Result`: **Success**

   The example result below indicates that the payment was successful. The transaction identifier for this payment is **oLkO0012498220087000.981517998282382C**.

   **Payment response**

   ```json
   {
      "SaleToPOIResponse":{
         "MessageHeader":{...},
         "PaymentResponse":{
            "POIData":{
               "POITransactionID":{
                  "TransactionID": "oLkO0012498220087000.981517998282382C"
              },
              ...
            },
            "Response":{
              "Result":"Success"
            },
            ...
         },
         "PaymentReceipt":{...}
      }
   }
   ```

## Next steps

Now that both your sales channels are able to create and recognize customers, you are able to offer these customers with better purchasing experiences.

[Payment-linked loyalty](/unified-commerce/loyalty-program/payment-linked-loyalty)

[Reward your returning customers with a payment-linked loyalty program.](/unified-commerce/loyalty-program/payment-linked-loyalty)

[Referenced refunds](/unified-commerce/referenced-refunds)

[Refund purchases from any sales channel.](/unified-commerce/referenced-refunds)
