Get card pan

The card PAN is an important component of the card. Once this information is obtained, anyone can potentially withdraw funds from the card.

We recommend using RSA encryption. When you obtain the API key, we will ask you to provide your RSA public key. You can follow the process below to decrypt it. (Of course, we understand the differences in programming languages, and we will do our best to provide demos to assist you. You can also choose not to encrypt the card PAN.)

  1. Generate a public-private key pair and securely store your private key.
# Generate a private key in PKCS#1 format
openssl genrsa -out private_key.pem 2048

# Convert to PKCS#8 format
openssl pkcs8 -topk8 -inform PEM -in private_key.pem -out private_key_pkcs8.pem -nocrypt

# Extract public key
openssl rsa -in private_key_pkcs8.pem -pubout -out public_key.pem
  1. Request private-info uri to obtain Card PAN information.
{
    "code": 0,
    "message": "",
    "data": {
        "card_id": "5bb489f9-887c-4c38-8fcd-0e0e4f3f8c87",
        "encrypted_info": "XABI79vg4EhW8RsFPXUj0kuKmzHm5r1xzbjMxv+BJph2/d/pkapPErzD9Rz9UhMzF1qr6f363kmWRwQy22Z6nyeWJS8ZzpcTLPOGV8qyMeb17pslMTfwQNqJLmNwxah3oTBbgE8zRJ+dRRGzEB6AFX1CAugWDeXwLzKfLNOVuiIsmOhL4vOssHiEqKAzQUEGSAlRDvXXxZRNMEBTx3XqlXDgoTKbLKXPHKLuCQVstt5cmFRxKz7ItlaMWr9npvT09zxrp+Kp0mc6dCngNqoITe8+g3ocsH/zRyK8GBDBLuEVI2KkGO3vCBpDpg//L4mOw+M1BuZb7c14u31aLhOLBg=="
    },
    "timestamp": 1746540239473
}
  1. Decrypt with the private key.
import javax.crypto.Cipher;
import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Base64;

public class RsaDecryptExample {

    public static void main(String[] args) throws Exception {
        // 1. Reading a PKCS#8 private key
        String privateKeyPem = "-----BEGIN PRIVATE KEY-----\n" +
                "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCs7phu4hEAVQQZ\n" +
								".........."
                "-----END PRIVATE KEY-----";
        String privateKeyBase64 = privateKeyPem.replace("-----BEGIN PRIVATE KEY-----", "")
                        .replace("-----END PRIVATE KEY-----", "")
                        .replaceAll("\\s", "")
                        .replaceAll("\\s", "");

        System.out.println(privateKeyBase64);

        // 2. Decode Base64 and load the private key
        byte[] privateKeyBytes = Base64.getDecoder().decode(privateKeyBase64);
        PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
        PrivateKey privateKey = KeyFactory.getInstance("RSA").generatePrivate(keySpec);

        // 3. Initialize Cipher
        Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
        cipher.init(Cipher.DECRYPT_MODE, privateKey);

        // 4.Decrypt the ciphertext
        String ciphertextBase64 = "XABI79vg4EhW8RsFPXUj0kuKmzHm5r1xzbjMxv+BJph2/d/pkapPErzD9Rz9UhMzF1qr6f363kmWRwQy22Z6nyeWJS8ZzpcTLPOGV8qyMeb17pslMTfwQNqJLmNwxah3oTBbgE8zRJ+dRRGzEB6AFX1CAugWDeXwLzKfLNOVuiIsmOhL4vOssHiEqKAzQUEGSAlRDvXXxZRNMEBTx3XqlXDgoTKbLKXPHKLuCQVstt5cmFRxKz7ItlaMWr9npvT09zxrp+Kp0mc6dCngNqoITe8+g3ocsH/zRyK8GBDBLuEVI2KkGO3vCBpDpg//L4mOw+M1BuZb7c14u31aLhOLBg==";
        byte[] ciphertext = Base64.getDecoder().decode(ciphertextBase64);
        byte[] plaintextBytes = cipher.doFinal(ciphertext);

        // 5. Output plain text
        String plaintext = new String(plaintextBytes, StandardCharsets.UTF_8);
        System.out.println("result: " + plaintext);
    }
}

The obtained result is a JSON string, as follows for reference

{"account_number":"4327970120380602","cvv":"277","expire_m":"05","expire_y":"2028"}