> ## Documentation Index
> Fetch the complete documentation index at: https://adyen-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Reveal Card Details Using Standard Encryption Methods

> Allow your cardholders to see their card verification code (CVC), primary account number (PAN) and expiration date.

You can allow your cardholders to access the details of their Adyen-issued card within your app or website. This page explains how to implement a feature to securely reveal card details in your user interface, such as:

* Card verification code (CVC)
* Expiration date
* Primary account number (PAN)

To reveal the card details in your user interface, you must first get the card details data from Adyen. To securely request the data, you use a base64-encoded [RSA](https://en.wikipedia.org/wiki/RSA_\(cryptosystem\)) public key and an [Advanced Encryption Standard (AES)](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) key to generate an encrypted session key.

Use the session key to request Adyen to reveal the card details. This response contains the encrypted card data assigned to the Adyen-issued card. You must extract the data from the decrypted response and then reveal them to the cardholder in your interface.

The following sequence diagram illustrates the workflow.

![](https://docs.adyen.com/user/pages/docs/07.issuing/17.manage-card-data/02.reveal-card-details/pan-reveal.svg)

As shown in the diagram, the steps for revealing the card details are:

1. [Get an RSA public key from Adyen](#get-a-public-key).
2. [Generate an AES key](#generate-aes-key).
3. [Generate an encrypted session key](#generate-session-key).
4. [Request card details from Adyen](#request-card-reveal).
5. [Decrypt and reveal the card details in your user interface](#decrypt-card-details).

## Requirements

Ensure that:

* You have [API credentials](https://adyen-preview.mintlify.site/issuing/manage-access/api-credentials-web-service.md) for the [Configuration API](https://docs.adyen.com/api-explorer/balanceplatform/latest/overview).
* Your API credential has the **Bank Issuing PaymentInstrument Reveal Webservice** role.

## Get a public key from Adyen

You need a base64-encoded [RSA](https://en.wikipedia.org/wiki/RSA_\(cryptosystem\)) public key to [generate an encrypted session key](#encrypt-aes-key). You must use the [Configuration API](https://docs.adyen.com/api-explorer/balanceplatform/latest/overview) to get the public key from Adyen.

To get a public key:

1. Make a GET [/publicKey](https://docs.adyen.com/api-explorer/balanceplatform/latest/get/publicKey) request with the query parameter [purpose](https://docs.adyen.com/api-explorer/balanceplatform/latest/get/publicKey#query-purpose) set to **panReveal**.

   **Get a public key**

   #### curl

   ```bash theme={null}
   curl https://balanceplatform-api-test.adyen.com/bcl/v2/publicKey?purpose=panReveal \
   -H 'x-api-key: ADYEN_BALANCE_PLATFORM_API_KEY' \
   -H 'content-type: application/json' \
   -X GET \
   -d ''
   ```

   #### Java

   ```java theme={null}
   // Adyen Java API Library v33.0.0
   import com.adyen.Client;
   import com.adyen.enums.Environment;
   import com.adyen.model.balanceplatform.*;
   import java.time.OffsetDateTime;
   import java.util.*;
   import com.adyen.service.balancePlatform.*;

   Client client = new Client("ADYEN_BALANCE_PLATFORM_API_KEY", Environment.TEST);
   // Send the request
   ManageCardPinApi service = new ManageCardPinApi(client);
   PublicKeyResponse response = service.publicKey("String", "String", null);
   ```

   #### PHP

   ```php theme={null}
   <?php
   // Adyen PHP API Library v24.0.0
   use Adyen\Client;
   use Adyen\Environment;
   use Adyen\Service\BalancePlatform\ManageCardPINApi;

   $client = new Client();
   $client->setXApiKey("ADYEN_BALANCE_PLATFORM_API_KEY");
   $client->setEnvironment(Environment::TEST);

   $requestOptions['queryParams'] = array('purpose' => 'string', 'format' => 'string');

   // Send the request
   $service = new ManageCardPINApi($client);
   $response = $service->publicKey($requestOptions);
   ```

   #### C\#

   ```cs theme={null}
   // Adyen .net API Library v28.0.0
   using Adyen;
   using Environment = Adyen.Model.Environment;
   using Adyen.Model;
   using Adyen.Model.BalancePlatform;
   using Adyen.Service.BalancePlatform;

   var config = new Config()
   {
       XApiKey = "ADYEN_BALANCE_PLATFORM_API_KEY",
       Environment = Environment.Test
   };
   var client = new Client(config);

   // Send the request
   var service = new ManageCardPINService(client);
   var response = service.PublicKey(purpose: "string", format: "string");
   ```

   #### NodeJS (JavaScript)

   ```js theme={null}
   // Adyen Node API Library v23.3.0
   const { Client, BalancePlatformAPI } = require('@adyen/api-library');

   const client = new Client({ apiKey: "ADYEN_BALANCE_PLATFORM_API_KEY", environment: "TEST" });

   // Send the request
   const balancePlatformAPI = new BalancePlatformAPI(client);
   const response = balancePlatformAPI.ManageCardPINApi.publicKey("string", "string");
   ```

   #### Go

   ```go theme={null}
   // Adyen Go API Library v17.0.0
   import (
     "context"
     "github.com/adyen/adyen-go-api-library/v17/src/common"
     "github.com/adyen/adyen-go-api-library/v17/src/adyen"
     "github.com/adyen/adyen-go-api-library/v17/src/balancePlatform"
   )
   client := adyen.NewClient(&common.Config{
     ApiKey:      "ADYEN_BALANCE_PLATFORM_API_KEY",
     Environment: common.TestEnv,
   })

   // Send the request
   service := client.BalancePlatform()
   req := service.ManageCardPINApi.PublicKeyInput()
   req = req.Purpose("string").Format("string")
   res, httpRes, err := service.ManageCardPINApi.PublicKey(context.Background(), req)
   ```

   #### Python

   ```py theme={null}
   # Adyen Python API Library v13.3.0
   import Adyen

   adyen = Adyen.Adyen()
   adyen.client.xapikey = "ADYEN_BALANCE_PLATFORM_API_KEY"
   adyen.client.platform = "test" # The environment to use library in.

   query_parameters = {
     "purpose" : "string",
     "format" : "string"
   }

   # Send the request
   result = adyen.balancePlatform.manage_card_pin_api.public_key(query_parameters=query_parameters)
   ```

   #### Ruby

   ```rb theme={null}
   # Adyen Ruby API Library v10.1.1
   require "adyen-ruby-api-library"

   adyen = Adyen::Client.new
   adyen.api_key = 'ADYEN_BALANCE_PLATFORM_API_KEY'
   adyen.env = :test # Set to "live" for live environment

   # Create the request object(s)
   query_params = {
     :purpose => 'string',
     :format => 'string'
   }

   # Send the request
   result = adyen.balancePlatform.manage_card_pin_api.public_key(query_params: query_params)
   ```

   #### NodeJS (TypeScript)

   ```ts theme={null}
   // Adyen Node API Library v23.3.0
   import { Client, BalancePlatformAPI, Types } from "@adyen/api-library";

   const client = new Client({ apiKey: "ADYEN_BALANCE_PLATFORM_API_KEY", environment: "TEST" });

   // Send the request
   const balancePlatformAPI = new BalancePlatformAPI(client);
   const response = balancePlatformAPI.ManageCardPINApi.publicKey("string", "string");
   ```

   The response contains:

   * The public key
   * The expiry date of the public key

   **Response**

   ```json theme={null}
   {
       "publicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMII...",
       "publicKeyExpiryDate": "2023-12-12"
   }
   ```

2. Pass the [publicKey](https://docs.adyen.com/api-explorer/balanceplatform/latest/get/publicKey#responses-200-publicKey) to your front end.

## Generate an AES key

You need a 256-bit [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) encryption key to [generate an encrypted session key](#encrypt-aes-key). You can generate this key by using a random bit generator.

## Generate an encrypted session key

You need an encrypted symmetric session key to securely request the card details from Adyen. To generate the encrypted session key, encrypt the [AES key you generated](#generate-aes-key) key you generated in the previous step.

For the encryption, use:

* The [publicKey](https://docs.adyen.com/api-explorer/balanceplatform/latest/get/publicKey#responses-200-publicKey) that you [received from Adyen](#get-public-key).
* The [RSA](https://en.wikipedia.org/wiki/RSA_\(cryptosystem\)) encryption algorithm, version [PKCS 1](https://en.wikipedia.org/wiki/PKCS_1).

## Request card details from Adyen

Request from Adyen the encrypted card details as follows:

1. Make a POST [/paymentInstruments/reveal](https://docs.adyen.com/api-explorer/balanceplatform/latest/post/paymentInstruments/reveal) request and specify the following parameters:

   | Parameter | Description |
   | - | - |
   | [paymentInstrumentId](https://docs.adyen.com/api-explorer/balanceplatform/latest/post/paymentInstruments/reveal#request-paymentInstrumentId) | The unique identifier of the card for which you are revealing the details. |
   | [encryptedKey](https://docs.adyen.com/api-explorer/balanceplatform/latest/post/paymentInstruments/reveal#request-encryptedKey) | The [encrypted symmetric session key](#generate-session-key). |

   **Request for revealing the details of a card**

   #### curl

   ```bash theme={null}
   curl https://balanceplatform-api-test.adyen.com/bcl/v2/paymentInstruments/reveal \
   -H 'x-api-key: ADYEN_BALANCE_PLATFORM_API_KEY' \
   -H 'content-type: application/json' \
   -X POST \
   -d '{
       "paymentInstrumentId": "PI6789678967896789",
       "encryptedKey": "75989E8881284D10153ABACF022EEA09F5..."
   }'
   ```

   #### Java

   ```java theme={null}
   // Adyen Java API Library v25.0.0
   import com.adyen.Client;
   import com.adyen.enums.Environment;
   import com.adyen.model.balancePlatform.*;
   import java.time.OffsetDateTime;
   import java.util.*;
   import com.adyen.service.balancePlatform.*;

   Client client = new Client("ADYEN_API_KEY", Environment.TEST);

   // Create the request object(s)
   PaymentInstrumentRevealRequest paymentInstrumentRevealRequest = new PaymentInstrumentRevealRequest()
     .encryptedKey("75989E8881284D10153ABACF022EEA09F5...")
     .paymentInstrumentId("PI6789678967896789");

   // Make the API call
   PaymentInstrumentsApi service = new PaymentInstrumentsApi(client);
   PaymentInstrumentRevealResponse response = service.revealDataOfPaymentInstrument(paymentInstrumentRevealRequest, null);
   ```

   #### PHP

   ```php theme={null}
   // Adyen PHP API Library v17.4.0
   use Adyen\Client;
   use Adyen\Environment;
   use Adyen\Model\BalancePlatform\PaymentInstrumentRevealRequest;
   use Adyen\Service\BalancePlatform\PaymentInstrumentsApi;

   $client = new Client();
   $client->setXApiKey("ADYEN_API_KEY");
   $client->setEnvironment(Environment::TEST);


   // Create the request object(s)
   $paymentInstrumentRevealRequest = new PaymentInstrumentRevealRequest();
   $paymentInstrumentRevealRequest
     ->setEncryptedKey("75989E8881284D10153ABACF022EEA09F5...")
     ->setPaymentInstrumentId("PI6789678967896789");

   // Make the API call
   $service = new PaymentInstrumentsApi($client);
   $response = $service->revealDataOfPaymentInstrument($paymentInstrumentRevealRequest);
   ```

   #### C\#

   ```cs theme={null}
   // Adyen .net API Library v14.4.0
   using Adyen;
   using Environment = Adyen.Model.Environment;
   using Adyen.Model;
   using Adyen.Model.BalancePlatform;
   using Adyen.Service.BalancePlatform;

   var config = new Config()
   {
       XApiKey = "ADYEN_API_KEY",
       Environment = Environment.Test
   };
   var client = new Client(config);

   // Create the request object(s)
   PaymentInstrumentRevealRequest paymentInstrumentRevealRequest = new PaymentInstrumentRevealRequest
   {
     EncryptedKey = "75989E8881284D10153ABACF022EEA09F5...",
     PaymentInstrumentId = "PI6789678967896789"
   };

   // Make the API call
   var service = new PaymentInstrumentsService(client);
   var response = service.RevealDataOfPaymentInstrument(paymentInstrumentRevealRequest);
   ```

   #### NodeJS (JavaScript)

   ```js theme={null}
   // Adyen Node API Library v16.2.0
   // Require the parts of the module you want to use
   const { Client, BalancePlatformAPI } = require('@adyen/api-library');
   // Initialize the client object
   const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"});

   // Create the request object(s)
   const paymentInstrumentRevealRequest = {
     paymentInstrumentId: "PI6789678967896789",
     encryptedKey: "75989E8881284D10153ABACF022EEA09F5..."
   }

   // Make the API call
   const balancePlatformAPI = new BalancePlatformAPI(client);
   const response = balancePlatformAPI.PaymentInstrumentsApi.revealDataOfPaymentInstrument(paymentInstrumentRevealRequest);
   ```

   #### Go

   ```go theme={null}
   // Adyen Go API Library v9.3.0
   import (
     "context"
     "github.com/adyen/adyen-go-api-library/v9/src/common"
     "github.com/adyen/adyen-go-api-library/v9/src/adyen"
     "github.com/adyen/adyen-go-api-library/v9/src/balancePlatform"
   )
   client := adyen.NewClient(&common.Config{
     ApiKey:      "ADYEN_API_KEY",
     Environment: common.TestEnv,
   })

   // Create the request object(s)
   paymentInstrumentRevealRequest := balancePlatform.PaymentInstrumentRevealRequest{
     EncryptedKey: "75989E8881284D10153ABACF022EEA09F5...",
     PaymentInstrumentId: "PI6789678967896789",
   }

   // Make the API call
   service := client.BalancePlatform()
   req := service.PaymentInstrumentsApi.RevealDataOfPaymentInstrumentInput().PaymentInstrumentRevealRequest(paymentInstrumentRevealRequest)
   res, httpRes, err := service.PaymentInstrumentsApi.RevealDataOfPaymentInstrument(context.Background(), req)
   ```

   #### Python

   ```py theme={null}
   # Adyen Python API Library v12.2.0
   import Adyen

   adyen = Adyen.Adyen()
   adyen.client.xapikey = "ADYEN_API_KEY"
   adyen.client.platform = "test" # The environment to use library in.

   # Create the request object(s)
   json_request = {
     "paymentInstrumentId": "PI6789678967896789",
     "encryptedKey": "75989E8881284D10153ABACF022EEA09F5..."
   }

   # Make the API call
   result = adyen.balancePlatform.payment_instruments_api.reveal_data_of_payment_instrument(request=json_request)
   ```

   #### Ruby

   ```rb theme={null}
   # Adyen Ruby API Library v9.3.0
   require "adyen-ruby-api-library"

   adyen = Adyen::Client.new
   adyen.api_key = 'ADYEN_API_KEY'
   adyen.env = :test # Set to "live" for live environment

   # Create the request object(s)
   request_body = {
     :paymentInstrumentId => 'PI6789678967896789',
     :encryptedKey => '75989E8881284D10153ABACF022EEA09F5...'
   }

   # Make the API call
   result = adyen.balancePlatform.payment_instruments_api.reveal_data_of_payment_instrument(request_body)
   ```

   #### NodeJS (TypeScript)

   ```ts theme={null}
   // Adyen Node API Library v16.2.0
   // Require the parts of the module you want to use
   import { Client, BalancePlatformAPI, Types } from "@adyen/api-library";
   // Initialize the client object
   const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"});

   // Create the request object(s)
   const paymentInstrumentRevealRequest: Types.balancePlatform.PaymentInstrumentRevealRequest = {
     encryptedKey: "75989E8881284D10153ABACF022EEA09F5...",
     paymentInstrumentId: "PI6789678967896789"
   };

   // Make the API call
   const balancePlatformAPI = new BalancePlatformAPI(client);
   const response = balancePlatformAPI.PaymentInstrumentsApi.revealDataOfPaymentInstrument(paymentInstrumentRevealRequest);
   ```

   The response contains the [encryptedData](https://docs.adyen.com/api-explorer/balanceplatform/latest/post/paymentInstruments/reveal#responses-200-encryptedData).

   **Response**

   ```json theme={null}
   {
       "encryptedData": "4332F74A329924703EB12A6D5E7D...."
   }
   ```

2. Pass the [encryptedData](https://docs.adyen.com/api-explorer/balanceplatform/latest/post/paymentInstruments/reveal#responses-200-encryptedData) to your client.

## Decrypt and reveal card details

To reveal the card details you must:

1. Decrypt the `encryptedData` using:

   * The [AES key that you previously generated](#generate-aes-key).
   * The AES algorithm in [CBC mode](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation) with PKCS 5 padding.

2. Render the extracted card details in your app or on your website.

The following code is an example of decrypted card details.

**Decrypted card details**

```json theme={null}
{
    "cvc": "607",
    "expiration": {
        "month": "12",
        "year": "2023"
    },
    "pan":"5555341244441115"
}
```

After decrypting the data, you can reveal it to the cardholder in your interface.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.