Authentication Process

Secure Integration Steps for Merchant Authentication

Authentication Guide for Using Payelu APIs

This guide explains how to authenticate requests when interacting with our APIs. The authentication process ensures secure communication between your systems and our platform.


How Authentication Works

What We Provide

  • auth_point_id: Your unique identifier as a merchant (merchant ID).Example:
"dfr3s2c6-a45f-13e1-a2c5-3c58654b12s2"
  • auth_api_token: A shared API key used to generate the hash securely.Example: "9SAhxl0NMIOmMMb2l2ToPf83urWDyM32Me26sWPLSK"

What You Need to Do

  1. Generate a unique_key:
      • Create a random number with less than 10 digits.
      • Example: 1234567890
  1. Generate the hash:
      • Use the following algorithm to create a secure hash based on:
        • auth_api_token (shared API key)
        • auth_point_id (merchant ID)
        • unique_key (random number)

Algorithm for Hash Generation

Here is the algorithm in different programming languages:

Python Example

import hmac import hashlib def generate_hash(auth_api_token: str, auth_point_id: str, unique_key: int) -> str: part1 = str(unique_key).encode('utf-8') part2 = str(auth_point_id).encode('utf-8') message = part1 + part2 secret = auth_api_token.encode('utf-8') return hmac.new(secret, message, hashlib.sha256).hexdigest() # Example implementation auth_api_token = "9SAhxl0NMIOmMMb2l2ToPf83urWDyM32Me26sWPLSK" auth_point_id = "dfr3s2c6-a45f-13e1-a2c5-3c58654b12s2" # Your ID unique_key = 1234567890 # Random number generated_hash = generate_hash(auth_api_token, auth_point_id, unique_key) print("Generated Hash:", generated_hash)
 
PHP Example
<?php function generateHash($authApiToken, $authPointId, $uniqueKey) { $message = $uniqueKey . $authPointId; return hash_hmac('sha256', $message, $authApiToken); } // Example implementation $authApiToken = "9SAhxl0NMIOmMMb2l2ToPf83urWDyM32Me26sWPLSK"; $authPointId = "dfr3s2c6-a45f-13e1-a2c5-3c58654b12s2"; // Your ID $uniqueKey = 1234567890; // Random number $generatedHash = generateHash($authApiToken, $authPointId, $uniqueKey); echo "Generated Hash: " . $generatedHash; ?>
 
C# Example
using System; using System.Security.Cryptography; using System.Text; class Program { static string GenerateHash(string authApiToken, string authPointId, int uniqueKey) { string message = uniqueKey.ToString() + authPointId; byte[] keyBytes = Encoding.UTF8.GetBytes(authApiToken); byte[] messageBytes = Encoding.UTF8.GetBytes(message); using (var hmac = new HMACSHA256(keyBytes)) { byte[] hashBytes = hmac.ComputeHash(messageBytes); return BitConverter.ToString(hashBytes).Replace("-", "").ToLower(); } } static void Main() { string authApiToken = "9SAhxl0NMIOmMMb2l2ToPf83urWDyM32Me26sWPLSK"; string authPointId = "dfr3s2c6-a45f-13e1-a2c5-3c58654b12s2"; // Your ID int uniqueKey = 1234567890; // Random number string generatedHash = GenerateHash(authApiToken, authPointId, uniqueKey); Console.WriteLine("Generated Hash: " + generatedHash); } }
 

Header Structure

After generating the hash, include the following fields in the header of every request:
Field
Description
Example
auth_point_id
Your merchant identifier
"dffc82c6-a45f-49e1-a9c5-3c58978b3b23"
unique_key
Random number (unique per call)
1234567890
hash
The generated hash
"20298ff4f75f6925befd35ec706e09b693f06325c81"

Example Header:

json Copiar código { "auth_point_id": "dfr3s2c6-a45f-13e1-a2c5-3c58654b12s2", "unique_key": 1234567890, "hash": "fl498ff4f75f6925bede35ec706e09b693f2de25c81852dfd4b20d6af4e63se3" }

How to Test

You can test the authentication process using:
  1. Google Colab:
      • Copy the Python example provided above.
      • Run the script and verify the generated hash matches your backend validation.
  1. Postman:
      • Add the fields (auth_point_id, unique_key, hash) to the Headers section.
      • Send a request to our API endpoint and check the response.
 
 

API Backend Validation

When your request reaches our backend, the following steps occur:
  1. Retrieve the auth_api_token associated with your auth_point_id.
  1. Recalculate the hash using the same algorithm and inputs (auth_api_token, auth_point_id, unique_key).
  1. Compare the hashes:
      • If the hash matches the one sent in the header, the authentication succeeds.
      • If the hash does not match, the request is rejected.

Common Errors to Avoid

  1. Incorrect Hash Calculation:
      • Ensure the algorithm and input values match the documentation exactly.
  1. Missing Header Fields:
      • All three fields (auth_point_id, unique_key, hash) are required in every request.
  1. Improper Field Types:
      • auth_point_id: String (UUID format)
      • unique_key: Integer (less than 10 digits)
      • hash: String (SHA-256 hex digest)
 

Need Help?

If you have questions or encounter issues, feel free to reach out to our support team. We are here to help!
Name
Description
Example
api_url
Base URL for API requests
https://api.payelu.xyz
auth_point_id
Unique identifier for your merchant account in PAYELU
dfr3s2c6-a45f-13e1-a2c5-3c58654b12s2
service_id
Unique identifier for the payment service (e.g., bank transfers, PIX, payouts)
BT_ARS
auth_api_token
Shared secret string used for API authentication
9SAhxl0NMIOmMMb2l2ToPf83urWDyM32Me26sWPLSK
unique_key
A unique random number (provided by you) used to enhance security during API requests
1234567890
hash
A HMAC-SHA256 hash generated using auth_api_token, auth_point_id, and unique_key for authentication
20298ff4f75f6925befd35ec706e09b693f06325c81852defcb20d6a0d456bf7