Get Start

AMAR PAYMENT API Documentation

v1.0

Last updated: 2024-06-06


AMAR PAYMENT is a simple and secure payment automation platform designed to let you accept payments from your customers directly into your website using a complete REST API — mobile banking, local wallets and international gateways all in one place.

Base URL: https://pay.amarpayment.site/

Authentication

POST Headers Required

All API requests require authentication using the following headers.

HEADER NAME Content-Type
VALUE application/json
REQUIRED YES
HEADER NAME API-KEY
VALUE App key from API credentials
REQUIRED YES
HEADER NAME SECRET-KEY
VALUE Secret key from API credentials
REQUIRED YES
HEADER NAME BRAND-KEY
VALUE Brand key from Brands
REQUIRED YES

APIs

AMAR PAYMENT Payment Gateway enables merchants to receive money from customers by temporarily redirecting them to the gateway. It connects multiple payment terminals including card systems, mobile financial services, and local/international wallets. Once payment is complete, the customer returns to the merchant's site and the merchant receives a notification with transaction details.

POST Create Payment URL

Live API endpoint used to generate a payment URL.

https://pay.amarpayment.site/api/payment/create
POST Verify Payment

Used to verify the status of a completed transaction.

https://pay.amarpayment.site/api/payment/verify

Parameters — Create Payment

FIELD NAME cus_name
DESCRIPTION Customer full name
REQUIRED YES
EXAMPLE John Doe
FIELD NAME cus_email
DESCRIPTION Email address of the customer
REQUIRED YES
EXAMPLE john@gmail.com
FIELD NAME amount
DESCRIPTION Total payable amount. Skip trailing zeros for natural numbers.
REQUIRED YES
EXAMPLE 10 or 10.50
FIELD NAME success_url
DESCRIPTION URL the customer returns to after successful payment.
REQUIRED YES
EXAMPLE https://yourdomain.com/success.php
FIELD NAME cancel_url
DESCRIPTION URL to return the customer to your product/home page.
REQUIRED YES
EXAMPLE https://yourdomain.com/cancel.php
FIELD NAME meta_data
DESCRIPTION Any JSON formatted custom data.
REQUIRED NO
EXAMPLE JSON formatted

Parameters — Verify Payment

FIELD NAME transaction_id
DESCRIPTION Transaction ID received as a query parameter from the success URL.
REQUIRED YES
EXAMPLE OVKPXW165414

Integration

You can integrate our payment gateway into your PHP, Laravel, WordPress and WooCommerce sites.

Sample Request

Create Payment

POST /v2/order/synchronize/prepare
Initialize Payment Parameters

Variables needed to POST to initialize the payment process in the gateway URL.

Field Name Description Req Example
dn_cn Customer Full Name YES John Doe
dn_ce Customer Email YES customer@email.com
dn_am Total amount (skip trailing zeros) YES 10
dn_su Success URL YES yourdomain.com/success
dn_cu Cancel URL YES yourdomain.com/cancel
dn_wu Webhook IPN URL NO yourdomain.com/webhook
dn_mt JSON Meta Data NO {"phone":"016**"}
dn_rt Return Type NO GET
<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.doniapay.com/v2/order/synchronize/prepare',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{"success_url":"yourdomain.com/success","cancel_url":"yourdomain.com/cancel","metadata":{"phone":"016****"},"amount":"10"}',
  CURLOPT_HTTPHEADER => array(
    'X-Signature-Key: YOUR_API_KEY',
    'Content-Type: application/json',
    'donia-signature: YOUR_HMAC_SIGNATURE'
  ),
));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;

$client = new Client();
$headers = [
  'X-Signature-Key' => 'YOUR_API_KEY',
  'Content-Type'    => 'application/json',
  'donia-signature' => 'YOUR_HMAC_SIGNATURE'
];
$body = '{
  "success_url": "yourdomain.com/success",
  "cancel_url": "yourdomain.com/cancel",
  "metadata": {"phone": "016****"},
  "amount": "10"
}';

$response = $client->post('https://api.doniapay.com/v2/order/synchronize/prepare', [
  'headers' => $headers,
  'body'    => $body
]);
echo $response->getBody();
?>
const axios = require('axios');

const data = JSON.stringify({
  "success_url": "yourdomain.com/success",
  "cancel_url": "yourdomain.com/cancel",
  "metadata": { "phone": "016****" },
  "amount": "10"
});

const config = {
  method: 'post',
  url: 'https://api.doniapay.com/v2/order/synchronize/prepare',
  headers: {
    'X-Signature-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
    'donia-signature': 'YOUR_HMAC_SIGNATURE'
  },
  data: data
};

axios.request(config)
  .then(res => console.log(res.data))
  .catch(err => console.error(err));
import requests
import json

url = "https://api.doniapay.com/v2/order/synchronize/prepare"
payload = json.dumps({
  "success_url": "yourdomain.com/success",
  "cancel_url": "yourdomain.com/cancel",
  "metadata": {"phone": "016****"},
  "amount": "10"
})
headers = {
  'X-Signature-Key': 'YOUR_API_KEY',
  'Content-Type': 'application/json',
  'donia-signature': 'YOUR_HMAC_SIGNATURE'
}

response = requests.post(url, headers=headers, data=payload)
print(response.text)
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {
  url := "https://api.doniapay.com/v2/order/synchronize/prepare"
  payload := strings.NewReader(`{"success_url":"yourdomain.com/success","cancel_url":"yourdomain.com/cancel","metadata":{"phone":"016****"},"amount":"10"}`)

  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("X-Signature-Key", "YOUR_API_KEY")
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("donia-signature", "YOUR_HMAC_SIGNATURE")

  client := &http.Client{}
  res, err := client.Do(req)
  if err != nil { fmt.Println(err); return }
  defer res.Body.Close()

  body, _ := ioutil.ReadAll(res.Body)
  fmt.Println(string(body))
}
Response Details
Field NameTypeDescription
status bool TRUE
message String Message for Status
payment_url String Payment Link (where customers will complete their payment)
status bool FALSE
message String Message associated with the error response
⚡ After completing the payment, the customer is redirected to the success or cancel page based on transaction status with the following query parameters:
yourdomain.com/(success|cancel)?transactionId=******&paymentMethod=***&paymentAmount=**.**&paymentFee=**.**&status=pending|success|failed

Verify Request


<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://pay.amarpayment.site/api/payment/verify',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{"transaction_id":"ABCDEFH"}',
  CURLOPT_HTTPHEADER => array(
    'API-KEY: gnXi7etgWNhFyFGZFrOMYyrmnF4A1eGU5SC2QRmUvILOlNc2Ef',
    'Content-Type: application/json',
    'SECRET-KEY: Secret key From API credentials',
    'BRAND-KEY: Brand key From Brands'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

?>
      

<?php
$client = new Client();
$headers = [
  'API-KEY' => 'gnXi7etgWNhFyFGZFrOMYyrmnF4A1eGU5SC2QRmUvILOlNc2Ef',
  'Content-Type' => 'application/json',
  'SECRET-KEY' => 'Secret key From API credentials',
  'BRAND-KEY' => 'Brand key From Brands'
];
$body = '{
  "transaction_id": "ABCDEFH"
}';
$request = new Request('POST', 'https://pay.amarpayment.site/api/payment/verify', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();

?>
      

const axios = require('axios');
let data = JSON.stringify({
  "transaction_id": "ABCDEFH"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://pay.amarpayment.site/api/payment/verify',
  headers: { 
    'API-KEY': 'gnXi7etgWNhFyFGZFrOMYyrmnF4A1eGU5SC2QRmUvILOlNc2Ef', 
    'Content-Type': 'application/json',
    'SECRET-KEY': 'Secret key From API credentials',
    'BRAND-KEY': 'Brand key From Brands'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
      

import http.client
import json

conn = http.client.HTTPSConnection("local.pay.expensivepay.com")
payload = json.dumps({
  "transaction_id": "ABCDEFH"
})
headers = {
  'API-KEY': 'gnXi7etgWNhFyFGZFrOMYyrmnF4A1eGU5SC2QRmUvILOlNc2Ef',
  'Content-Type': 'application/json',
  'SECRET-KEY': 'Secret key From API credentials',
  'BRAND-KEY': 'Brand key From Brands'
}
conn.request("POST", "/api/payment/verify", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
      

package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://pay.amarpayment.site/api/payment/verify"
  method := "POST"

  payload := strings.NewReader(`{"transaction_id":"ABCDEFH"}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("API-KEY", "gnXi7etgWNhFyFGZFrOMYyrmnF4A1eGU5SC2QRmUvILOlNc2Ef")
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("SECRET-KEY", "Secret key From API credentials")
  req.Header.Add("BRAND-KEY", "Brand key From Brands")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
      
Sample Response

{
    "cus_name": "John Doe",
    "cus_email": "john@gmail.com",
    "amount": "900.000",
    "transaction_id": "OVKPXW165414",
    "metadata": {
      "phone": "015****",
    },
    "payment_method": "bkash",
    "status": "COMPLETED"
}
      

Response Details

Field Name Type Description
Success Response
status string COMPLETED or PENDING or ERROR
cus_name String Customer Name
cus_email String Customer Email
amount String Amount
transaction_id String Transaction id Generated by System
metadata json Metadata used for Payment creation
Error Response
status bool FALSE
message String Message associated with the error response

Modules

WordPress Module

Integrate our payment gateway into your WordPress website effortlessly — e-commerce, membership sites, or donation platforms.

Download Now

WHMCS Module

Accept payments, manage invoices and track transactions seamlessly within your WHMCS setup.

Download Now

SMM Panel Module

Streamline the payment process for your social media marketing services with a smooth client experience.

Download Now

Mobile App

Manage transactions on the go with our official mobile app.

Download Now