- Get a public key from Adyen.
- Generate an AES key.
- Generate an encrypted session key.
- Generate an encryption token.
- Generate an encrypted PIN block.
- Request a PIN change to Adyen.
Requirements
Make sure that:- You have API credentials for the Configuration API.
- Your API credential has the Bank Issuing PIN Change Webservice role.
Get a public key from Adyen
You need a base64-encoded RSA public key to generate an encrypted session key. You must use the Configuration API to get the public key from Adyen. To get a public key:-
Make a GET /publicKey request with the query parameter purpose set to pinChange.
Get a public key
curl
Java
PHP
C#
NodeJS (JavaScript)
Go
Python
Ruby
NodeJS (TypeScript)
The response contains:- The public key
- The expiry date of the public key
- Pass the publicKey to your front end.
Generate an AES key
You need a 256-bit AES encryption key to generate an encrypted session 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 PIN change to Adyen. To generate the encrypted session key, encrypt the AES key you generated in the previous step. For the encryption, use:- The publicKey that you received from Adyen.
- The RSA encryption algorithm, version PKCS 1.
Generate an encryption token
You need a token as an intermediate step to generate the encrypted PIN block. To get a token, generate a 16-digit random number that does not contain zeros. Example token: 8374188662676926Generate an encrypted PIN block
You must embed the PIN in an encrypted PIN block before sending it to Adyen. Encrypt the PIN block using the ISO format 4 (ISO-4) encryption method. To encrypt a PIN block using the ISO format 4 method:-
Format the token that you previously generated. To do this, create a hexadecimal string of 32 characters as follows:
- “4” as the first character
- The token
- The character “0” repeated 15 times.
Example: 4 + 8374188662676926 + 000000000000000
- Convert the formatted token into a 16-byte array.
-
Format the new PIN. To do this, create a hexadecimal string of 32 characters as follows:
- The string “44”
- The new PIN
- 10 times the character “A”
- 16 random hexadecimal characters
Example: 44 + 5454 + AAAAAAAAAA + 70cd3917e96891f8
- Convert the formatted PIN into a 16-byte array.
- Encrypt the 16-byte PIN data using AES in ECB mode with the key that you previously generated.
- Combine the 16-byte token data and the encrypted PIN data into one 16-byte array by doing an XOR.
- Encrypt the combined array using AES in ECB mode with the key that you previously generated.
- Convert this encrypted data into a hexadecimal string.
Request a PIN change to Adyen
To request a PIN change, make a POST /pins/change call and specify the following request parameters:
The following code sample shows how to request a PIN change.
Request a PIN change