Integration Guide
Overview
1.
Authentication
accessToken
is used to authenticate the user and allow operations on the API. All APIs use the accessToken
as the authentication mechanism for client requests. Your access token should always be kept confidential and secure.When making a request, you need to first obtain the
accessToken
and include it in the request header Authorization
.Generating Public and Private Keys
api_private.pem
as your API RSA private key):openssl genpkey -out api_private.pem -algorithm RSA -pkeyopt rsa_keygen_bits:4096
Use OpenSSL to generate the corresponding public key for the RSA private key (
api_public.pem
as your API RSA public key):openssl rsa -in api_private.pem -out api_public.pem -pubout
Saving Merchant Public Key.You must include both the header and footer when saving the key.
-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA6v8JgHmwJS1gK1IR9jpb
fHD+mEEwAteV13pmM94ribQELnhbQegvmH/aCDg7nkIZasyQ5H3mfNa1Fuv6IATY
9Of58gA9TEUkcxzV0JrT0zVpkxmCaejUVA63gi6AVqQZWn4YqRBAqzVzgq4CpOG+
dGTXy/GS62+EdDvF3jrhPcECAwEAAQ==
-----END PUBLIC KEY-----
RSA Encryption and Decryption for API Interaction
1. Request Encryption Process
1.
2.
body = {'param1': 'value1', 'param2': 'value2'}
.3.
encrypt_data_with_public_key(body, public_key_str)
, where public_key_str
is the known VM platform public key string. See the example below for the encrypt_data_with_public_key
function.4.
content
.5.
{'content': content}
to the corresponding API endpoint.2. Response Decryption Process
1.
{'code': 0, 'msg':'ok', 'data': 'encrypted data'}
.2.
data
field from the response.3.
data
. Call the decryption function decrypt_data_with_private_key(encrypted_data, private_key_str)
, where encrypted_data
is the encrypted data from the response and private_key_str
is the known private key string. See the example below for the decrypt_data_with_private_key
function (with padding using PKCS#1 v1.5).4.
5.
3. Encryption and Decryption Function Explanation
(1) Encryption Function
encrypt_data_with_public_key
data
: The data to be encrypted, which should be a serializable object, typically a dictionary.public_key_str
: The public key string.RSA.import_key
method to load the provided public key string.PKCS1_v1_5
encryption method to encrypt the byte-encoded JSON string.(2) Decryption Function
decrypt_data_with_private_key
encrypted_data
: The hex-encoded encrypted data string.private_key_str
: The private key string.RSA.import_key
method to load the provided private key string.PKCS1_v1_5
decryption method to decrypt the Base64 decoded data.1.
PKCS#1 v1.5
padding during encryption.4. Usage Example
your_public_key
and your_private_key
with actual public and private key strings. Additionally, ensure the data format is as expected and no errors occur during encryption and decryption.1.
2.
IP Whitelist
Request Example
Base Request URL
https://sandbox-api.vmcardio.com/
Request Parameters Before Encryption
Example of business request parameters before encryption
{
"apiKey": "341916e58af445f8aadeb95*******",
"timestamp": "1623038312088",
"rsaType": "ECB_OAEP",
"aesType": "GCM_NOPADDING",
"bizContent": {
"page": 1,
"pageSize": 1
}
}
Request Parameters After Encryption
{
"apiKey": "341916e58af445f8aadeb95170******",
"timestamp": "1628652100447",
"bizContent": "qjFMZXs2n+CxnrNGoaZmGrKQzPosy6QbWEumCMkGOEw=",
"key": "gYZvuXdJADuaLYMU3z8q5vOtld62PSaPxrrhhr4UGwWbZm7Pw3/VImzHrd3oNy1XT8R55V7pbpQOBVdbmTev/rESnuaXlGofkB04JWAaRCIPytEKMHUNXZXEU9GLVppYst7bgiekMDIDScS4AkD75eDG8zru5Gr+gTxU4AYyHSzB0deQnxmNRemwZn+jaNgNs7WeBcuQWR1Cq2+1At8FlAqF5XzEaeQ3x1Q0N3iaLzSiXHQRYqP1Q6V6/aiIXchin/X9bBRYL618utjm4k0qoXU8Rw2JeEKzn7m2ShyyQQ31zX/rQ1xf0ar5PDtJPU/qYp9Kr4oVtcN6yHdG802nLqpGYlHlMvxy9vpnGFXb9oxh4xYnp0qRUfKLyJIylc3qhq6spHyWnuC5XV1S4lH+rIPNF1icV08ex7pjps2jvTICBzIIPExBamh1n00RcxZbkGqxYfRZ7SLTUCH06EaV5lP8yXNe3fNWjHk4mppaVDj0QFagqTzBM9AwMfHs1dOeDmcwkTacKQsvNRu3l5uZFQYkaUeVB9m3AhKw3lyl2oJIfJgYeBLJEHMGFVZXP92z8+J5KrZEVfkL8F80XkB3sXRP0BiIv/9Mm4VrjopYoDWyX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