Skip to main content

Sample Client Code

PayGlocal provides sample client code to handle the cryptographic complexity of signing and encrypting requests. Contact your PayGlocal representative or reach out to support@payglocal.in to request access to the GitHub repository or sample code package. The client code is available in multiple languages. Once received, follow the configuration steps below.

Configuration Properties

The sample code uses a properties file with the following attributes:

Step-by-Step Configuration

1

Set Your Merchant ID

Set merchantId to the PayGlocal-provided Merchant ID for your environment (UAT or Production).
2

Set Key File Paths

Point privateKeyPath and publicCertPath to the locations where you have stored the downloaded PVT-KEY and PUBCERT files.
3

Extract and Set KIDs

PVT-KEY KID: Take the portion of your PVT-KEY filename before the underscore.
PUBCERT KID: Take the portion of the PUBCERT filename before _glocal.cert.
4

Enable Payload Encryption

Set payloadEncryption = true. When enabled, the client code automatically encrypts the JSON request body in JWE format using the PUBCERT before sending it to PayGlocal.PayGlocal strongly recommends using payload encryption for all environments.

What the Client Code Does

When payloadEncryption = true, the client code performs the following steps for each API call:

API Endpoints

REST API Base URLs

PayGlocal Control Center (GCC) URLs

Portfolio Merchant (Parent-Child MID)

For clients with a parent-child MID setup, you can use the parent’s keys to sign transactions for child MIDs. Add the following header to all child MID transactions:
Pass the child MID in the merchantId field of the request payload.

Next Steps

With your client code configured, proceed to integrate the payment services:

GPI Service

Initiate payments through the PayGlocal Payment Initiation service.

Integration Flow

Understand the end-to-end payment flow before writing your first request.