Who should use this guideThis guide is intended for merchants who:
- Use Payrails as a payment orchestrator
- Use 2C2P to accept payments across South-East Asia
- Want to accept card payments (and VietQR in Vietnam) through 2C2P’s hosted payment page
Create and configure a 2C2P integration in Payrails
Following are the initial steps to set up 2C2P:- Log in to the Payrails portal.
- Go to Settings → Integrations → Payments.
- Select Add instance to create a new 2C2P integration configuration.
- Select the workspaces where this integration should be available.
About workspacesWorkspaces determine where this integration is available. They let you isolate provider setups by region or business line, or share the same configuration across multiple workspaces.
Step 1: Choose the integration type
Select Payment and continue to the next step.
Step 2: Choose the provider
Select 2C2P and continue to the next step.
Step 3: Configure your 2C2P integration

Integration instance name
An integration instance is a specific payment provider setup in Payrails. You can create multiple instances for each provider based on region, currency, or business needs. Choose a clear, consistent name, as it is used in routing.In Payrails
- Enter an Instance name for your integration.

Merchant ID
In 2C2P- In your 2C2P Merchant Portal, locate and copy your Merchant ID.
- Paste the value into the Merchant ID field.

Secret key
In 2C2P- In your 2C2P Merchant Portal, open your API / developer settings and copy the Secret key.
- Paste the value into the Secret key field.

Merchant private key & 2C2P public key (for capture, void & refund)
These credentials are only required to capture, void or
refund payments through Payrails. Authorization and the hosted payment page
work with the Merchant ID and Secret key alone, so you can add these keys later.
Before you start, make sure you have:
- Access to the 2C2P Merchant Portal, with the Merchant Public Keys panel visible on the account settings page.
- Someone who can run two terminal commands. No development work is involved.
- Confirmation of the environment you’re configuring, sandbox or production. Each environment needs its own keys.
1. Create the key pair and certificate
2C2P requires the public half as an X.509 certificate, not a bare public key. The first command creates the private key and a matching self-signed certificate. The second converts the certificate into the single-line value the 2C2P portal expects.payrails-2c2p-private.pem: the private key. It goes to Payrails only.payrails-2c2p-cert.pem: the certificate. Keep it to check the fingerprint and expiry date.payrails-2c2p-cert-base64.txt: the value to paste into the 2C2P portal.
PRIVATE KEY) or PKCS#1 (RSA PRIVATE KEY) format. Convert a PKCS#12 bundle or a passphrase-protected key before you use it.
2. Add your certificate to the 2C2P portal
In 2C2P- In the Merchant Public Keys panel, select Add new.
- Enter a KeyID that identifies the key, for example
Payrails-2026. - Paste the full contents of
payrails-2c2p-cert-base64.txtinto Public Key, as one line with no line breaks or spaces. Paste only the base64 value, without the-----BEGIN CERTIFICATE-----and-----END CERTIFICATE-----lines. - Select Key Is Default, then select Create.


- In the Payment Result URL panel, select Edit.
- Paste the same single-line certificate into Server-to-server API - Public key. Leave the other fields as they are.
- Select Save Changes.


3. Download 2C2P’s public key
In 2C2P- In the 2C2P Public Keys panel, select the JWE tab and download the Default Key JWT entry. Don’t use the PKCS7 key. The downloaded file is already PEM, despite its
.cerextension.

4. Add both keys in Payrails
In Payrails- Paste the contents of
payrails-2c2p-private.peminto the Merchant private key field. - Paste the contents of the file downloaded from the JWE tab into the 2C2P public key field.

5. Verify the keys
Make a small test payment, then refund it. A successful refund confirms that both keys are correct. To check the keys without a live request, confirm that the certificate matches the private key. The two hashes must be identical:
Common errors
Rotate the keys
Payrails doesn’t send a key ID, so 2C2P uses whichever key is the default. Switch the key in the 2C2P portal and in Payrails at the same time, and plan the rotation before the certificate expires.- Create a new key pair and certificate (step 1), and add it in the 2C2P portal under a new KeyID. Keep Default on the old key.
- Agree on a quiet window with your Payrails contact.
- In that window, make the new key the default, replace Server-to-server API - Public key with the new certificate, and update the Merchant private key in Payrails.
- Verify with a refund before you delete the old key in the 2C2P portal.
Payment methods
In Payrails- Under Payment methods, select the methods you want to enable for this integration: 2C2P (cards) and/or VietQR (Vietnam).
NotificationsPayrails sends the notification (webhook) URL to 2C2P
automatically with every payment, so there is no separate webhook to
configure in the 2C2P portal.

Request fields for 2C2P
Send these fields in the authorize request for card payments, in addition to the standard authorize fields. Required fields must be present for the payment to succeed. Payrails sends Optional fields to 2C2P when you include them. For more about meta fields, refer to Meta fields.Enable the integration
In Payrails- Select Save account to save the configuration and enable the integration.
- The Enabled status confirms that the 2C2P integration is active.
Next steps
- Run a test payment in test mode using a 2C2P test card (for example, Visa
4111 1111 1111 1111, any future expiry date, CVV123; complete the challenge on 2C2P’s hosted page with OTP123456). Use a supported currency such as THB or VND. - Verify that:
- The payment appears in your 2C2P Merchant Portal.
- The payment status updates correctly in Payrails.
- Once verified in test mode, repeat the setup in live mode.