Overview
Signature verification is a process to validate the integrity of messages exchanged between the Open Platform and merchants.
Signature operations typically occur in two scenarios:
1) HTTP requests (POST/PUT/DELETE) with request bodies sent from the merchant's backend;
2) Webhook notifications sent by PhotonPay to merchants.
The Open Platform uses an RSA private key for signing and an RSA public key for signature verification. Therefore, during the interaction, two pairs of RSA keys are involved: the merchant's RSA key pair and the platform's RSA key pair. Before initiating the integration, developers must configure the public key in the PhotonPay Merchant Platform.
To configure the public key in the PhotonPay Merchant Backend (as shown in the figure below), the header "-----BEGIN PUBLIC KEY-----" and the footer "-----END PUBLIC KEY-----" must be removed from the public key string.

Note: All APIs of the platform only support requests in JSON format. Ensure that the Content-Type: application/json header is included in the HTTP request headers.
Signature Process
Step 1: Generate MD5 Hash of Request Body
Use the JSON-formatted request body as the input for signature calculation, and encrypt it using the MD5 algorithm to generate an MD5 hash.
Step 2: RSA Signing and Base64 Encoding
Sign the MD5 hash obtained in Step 1 using the RSA private key. Encode the resulting signature with Base64 to get the final sign value.
Step 3: Add Signature to Request Header
Add a header parameter X-PD-SIGN to the HTTP request, and set its value to the sign string generated in Step 2.
Example
Assumptions
- Request body (JSON format):

- RSA Public Key (full format before processing):

- RSA Private Key (full format):

Calculation Results
- Result of Step 1 (MD5 hash):

- Result of Step 2 (RSA signature + Base64 encoding):

- Result of Step 3 (Header with signature):

Signature Demos
Important Reminder: These demos are for reference only. Do not directly copy or use them in production environments during actual development and integration.
1. Python Demo

2. Java Demo

3. PHP Demo

4. Go Demo




