Skip to main content
Version: v1.4.x Legacy

Basic Auth

Overview

This API uses Basic Authorization to authenticate clients. To access the API, clients must provide a valid username and password, which are encoded using Base64 and sent in the Authorization Header of each request.

Encoding Credentials in Base64

Basic Authentication requires encoding the username and password in the format:

username:password

This string must then be base64-encoded.

Usage Example

Assume your credentials are:

  • Username: client123

  • Password: secretpass

First, concatenate them with a colon:

client123:secretpass

Then, encode the string in Base64. The resulting encoded string would look something like:

Y2xpZW50MTIzOnNlY3JldHBhc3M=

Sending the Authentication Header

Once the credentials are encoded, include them in the Authorization header of your request.

A CURL example includes the Authorization Header:

curl --location '<PG_BASE_URL>/api/v1/payment/{PAYMENT_ID}/status' \
--header 'Authorization: Basic Y2xpZW50MTIzOnNlY3JldHBhc3M=' \
--header 'X-Terminal-Id: <TERMINAL_ID>' \

the example above explains how to include Basic Auth credentials in the GET Payment Status API endpoint.

Example: Basic Auth using JavaScript (Fetch API)

// e.g: for the following auth credentails.
// username: client123
// password: secretpass
// terminal ID: 111111
fetch('<PG_BASE_URL>/api/v1/payment/{PAYMENT_ID}/status', {
method: 'GET',
headers: {
Authorization: 'Basic ' + btoa('client123:secretpass'),
'X-Terminal-Id': '111111',
},
})
.then((response) => response.json())
.then((data) => console.log(data));

Example: Basic Auth with Paython

import requests
from requests.auth import HTTPBasicAuth

url = "https://api.example.com/resource"
response = requests.get(url, auth=HTTPBasicAuth('client123', 'secretpass'))
print(response.json())

Important Notes

  • The Authorization header must be included in every request.
  • Never share your credentials with unauthorized users.

Conclusion

By following these steps, merchants can authenticate and securely access the API using Basic Authentication. For any issues, please contact Payment Gateway Support Team.