Welcome To TituPay Docs Last updated: 2024-06-06

TituPay is a simple and Secure payment automation tool which is designed to use personal account as a payment gateway so that you can accept payments from your customer through your website where you will find a complete overview on how TituPay works and how you can integrate TituPay API in your website


API Introduction

TituPay Payment Gateway enables Merchants to receive money from their customers by temporarily redirecting them to www.TituPay.com. The gateway is connecting multiple payment terminal including card system, mobile financial system, local and International wallet. After the payment is complete, the customer is returned to the merchant's site and seconds later the Merchant receives notification about the payment along with the details of the transaction. This document is intended to be utilized by technical personnel supporting the online Merchant's website. Working knowledge of HTML forms or cURL is required. You will probably require test accounts for which you need to open accounts via contact with TituPay.com or already provided to you.

API Operation

REST APIs are supported in two environments. Use the Sandbox environment for testing purposes, then move to the live environment for production processing. When testing, generate an order url with your test credentials to make calls to the Sandbox URIs. When you’re set to go live, use the live credentials assigned to your new signature key to generate a live order url to be used with the live URIs. Your server has to support cURL system. For HTML Form submit please review after cURL part we provide HTML Post method URL also

Live API End Point (For Create Payment URL):

https://pay.titupay.com/api/payment/create

Payment Verify API:

https://pay.titupay.com/api/payment/verify

কাস্টম সাব-ডোমেইন (White-label) ব্যবহারকারীদের জন্য: আপনার মার্চেন্ট প্যানেলে কাস্টম সাব-ডোমেইন সক্রিয় থাকলে ডিফল্ট ডোমেইনের স্থানে আপনার সাব-ডোমেইন ব্যবহার করুন (যেমন: https://pay.yourbrand.com/api/payment/create ও https://pay.yourbrand.com/api/payment/verify)।

Parameter Details

Variables Need to POST to Initialize Payment Process in gateway URL

Field NameDescriptionRequiredExample Values
cus_nameCustomer Full NameYesJohn Doe
cus_emailEmail address of the customerYes[email protected]
amountThe total amount payable. Please note that you should skip the the trailing zeros in case the amount is a natural number.Yes 10 or 10.50 or 10.6
success_urlURL to which the customer will be returned when the payment is made successfully. The customer will be returned to the last page on the Merchant's website where he should be notify the payment successful.Yeshttps://yourdomain.com/sucess.php
cancel_urlURL to return customer to your product page or home page.Yeshttps://yourdomain.com/cancel.php
metadataPass any JSON formatted custom data (e.g. {"order_id": "123"}).NoJSON Object
webhook_urlInstant Payment Notification (IPN) webhook URL to receive payment status callback automatically.Nohttps://yourdomain.com/webhook.php

Variables Needs For Payment Verify

Field NameDescriptionRequiredExample Values
transaction_idTransaction id received as a query parameter from the success URL provided during payment creation.YesOVKPXW165414

Headers Details

Important: Always use your Brand Key in the API-KEY header (Collect from Merchant Dashboard → Brands → Brand Key).
Header NameDescription / Value
Content-Typeapplication/json
API-KEYYour Brand Key (From Merchant Dashboard → Brands)

Integration

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

Sample Request


      <?php

      $curl = curl_init();

      curl_setopt_array($curl, array(
        CURLOPT_URL => 'https://pay.titupay.com/api/payment/create',
        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":{"order_id":"123"},"amount":"10"}',
        CURLOPT_HTTPHEADER => array(
          'API-KEY: YOUR_BRAND_KEY',
          'Content-Type: application/json'
        ),
      ));

      $response = curl_exec($curl);

      curl_close($curl);
      echo $response;

      ?>
      

      <?php
      $client = new Client();
      $headers = [
        'API-KEY' => 'YOUR_BRAND_KEY',
        'Content-Type' => 'application/json'
      ];
      $body = '{
        "success_url": "yourdomain.com/success",
        "cancel_url": "yourdomain.com/cancel",
        "metadata": {
          "order_id": "123"
        },
        "amount": "10"
      }';
      $request = new Request('POST', 'https://pay.titupay.com/api/payment/create', $headers, $body);
      $res = $client->sendAsync($request)->wait();
      echo $res->getBody();
      ?>
      

      const axios = require('axios');
      let data = JSON.stringify({
        "success_url": "yourdomain.com/success",
        "cancel_url": "yourdomain.com/cancel",
        "metadata": {
          "order_id": "123"
        },
        "amount": "10"
      });

      let config = {
        method: 'post',
        maxBodyLength: Infinity,
        url: 'https://pay.titupay.com/api/payment/create',
        headers: { 
          'API-KEY': 'YOUR_BRAND_KEY', 
          'Content-Type': 'application/json'
        },
        data : data
      };

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


      

      import requests
      import json

      url = "https://pay.titupay.com/api/payment/create"

      payload = json.dumps({
        "success_url": "yourdomain.com/success",
        "cancel_url": "yourdomain.com/cancel",
        "metadata": {
          "order_id": "123"
        },
        "amount": "10"
      })
      headers = {
        'API-KEY': 'YOUR_BRAND_KEY',
        'Content-Type': 'application/json'
      }

      response = requests.request("POST", url, headers=headers, data=payload)

      print(response.text)
      

      package main

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

      func main() {

        url := "https://pay.titupay.com/api/payment/create"
        method := "POST"

        payload := strings.NewReader(`{"success_url":"yourdomain.com/success","cancel_url":"yourdomain.com/cancel","metadata":{"order_id":"123"},"amount":"10"}`)

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

        if err != nil {
          fmt.Println(err)
          return
        }
        req.Header.Add("API-KEY", "YOUR_BRAND_KEY")
        req.Header.Add("Content-Type", "application/json")

        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))
      }
      
// Step 1: In settings.gradle: include ':app', ':paymentgateway'
// Step 2: In app/build.gradle: implementation project(':paymentgateway')

import com.paymentgateway.sdk.PaymentGateway;
import com.paymentgateway.sdk.PaymentCallback;
import com.paymentgateway.sdk.PaymentResult;

PaymentGateway.init(this)
    .setApiKey("YOUR_BRAND_KEY") // Collect from Merchant Dashboard -> Brands
    .setBaseUrl("https://pay.titupay.com/")
    .setAmount(100.0)
    .setCustomerName("Rahim Ahmed")
    .setCustomerEmail("[email protected]")
    .setCustomerPhone("017XXXXXXXX")
    .setSuccessUrl("https://titupay.com/success.php")
    .setCancelUrl("https://titupay.com/cancel.php")
    .setWebhookUrl("https://titupay.com/webhook.php")
    .addMetadata("order_id", "ORD-1002")
    .startPayment(new PaymentCallback() {
        @Override
        public void onSuccess(PaymentResult result) {
            String trxId = result.getTransactionId();
            String method = result.getPaymentMethod();
            double paid = result.getAmount();
            // Handle successful payment in your app
        }

        @Override
        public void onCancelled() {
            // User cancelled payment
        }

        @Override
        public void onError(String errorMessage) {
            // Error occurred
        }
    });
// Step 1: In settings.gradle: include(":app", ":paymentgateway")
// Step 2: In app/build.gradle.kts: implementation(project(":paymentgateway"))

import com.paymentgateway.sdk.PaymentGateway
import com.paymentgateway.sdk.PaymentCallback
import com.paymentgateway.sdk.PaymentResult

PaymentGateway.init(this)
    .setApiKey("YOUR_BRAND_KEY")
    .setBaseUrl("https://pay.titupay.com/")
    .setAmount(100.0)
    .setCustomerName("Rahim Ahmed")
    .setCustomerEmail("[email protected]")
    .setSuccessUrl("https://titupay.com/success.php")
    .setCancelUrl("https://titupay.com/cancel.php")
    .setWebhookUrl("https://titupay.com/webhook.php")
    .addMetadata("order_id", "ORD-1002")
    .startPayment(object : PaymentCallback {
        override fun onSuccess(result: PaymentResult) {
            val trxId = result.transactionId
            val method = result.paymentMethod
            val paid = result.amount
            // Handle payment success
        }

        override fun onCancelled() {
            // User cancelled
        }

        override fun onError(errorMessage: String) {
            // Error occurred
        }
    })

Response Details

Field NameTypeDescription
Success Response
statusboolTRUE
messageStringMessage for Status
payment_urlStringPayment Link (where customers will complete their payment)
Error Response
statusboolFALSE
messageStringMessage associated with the error response
Completing Payment Page task you will be redirected to success or cancel page based on transaction status with the following Query Parameters: yourdomain.com/(success/cancel)?transactionId=******&paymentMethod=***&paymentAmount=**.**&paymentFee=**.**&status=pending or success or failed

Verify Request

<?php

$payload = array(
    "transaction_id" => "OVKPXW165414"
);

$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL            => 'https://pay.titupay.com/api/payment/verify',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_POSTFIELDS     => json_encode($payload),
    CURLOPT_HTTPHEADER     => array(
        'API-KEY: YOUR_BRAND_KEY',
        'Content-Type: application/json'
    ),
));

$response = curl_exec($curl);
curl_close($curl);

echo $response;
?>
<?php
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;

$client = new Client();
$headers = [
    'API-KEY'      => 'YOUR_BRAND_KEY',
    'Content-Type' => 'application/json'
];

$body = json_encode([
    "transaction_id" => "OVKPXW165414"
]);

$request = new Request('POST', 'https://pay.titupay.com/api/payment/verify', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
?>
const axios = require('axios');

const data = {
  transaction_id: "OVKPXW165414"
};

axios.post('https://pay.titupay.com/api/payment/verify', data, {
  headers: {
    'API-KEY': 'YOUR_BRAND_KEY',
    'Content-Type': 'application/json'
  }
})
.then((response) => {
  console.log(response.data);
})
.catch((error) => {
  console.error(error);
});
import requests

url = "https://pay.titupay.com/api/payment/verify"

payload = {
    "transaction_id": "OVKPXW165414"
}

headers = {
    'API-KEY': 'YOUR_BRAND_KEY',
    'Content-Type': 'application/json'
}

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

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

func main() {
    url := "https://pay.titupay.com/api/payment/verify"

    jsonData := []byte(`{"transaction_id":"OVKPXW165414"}`)

    req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    if err != nil {
        fmt.Println(err)
        return
    }

    req.Header.Set("API-KEY", "YOUR_BRAND_KEY")
    req.Header.Set("Content-Type", "application/json")

    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))
}

Sample Verify Response (JSON)

{
  "cus_name": "John Doe",
  "cus_email": "[email protected]",
  "amount": "100.00",
  "transaction_id": "OVKPXW165414",
  "metadata": "{\"order_id\":\"1001\"}",
  "payment_method": "bkash",
  "status": "COMPLETED"
}

Response Details

Field NameTypeDescription
Response Fields
statusstringCOMPLETED (success), PENDING (under review), or ERROR
transaction_idstringGateway transaction identifier
amountstringAmount paid in BDT
payment_methodstringPayment method used (e.g. bkash, nagad, rocket)
cus_namestringCustomer name provided during checkout
cus_emailstringCustomer email provided during checkout
metadatastring / jsonCustom metadata passed during payment creation

WordPress Module

Integrate our payment gateway into your WordPress website effortlessly. Whether you run an e-commerce store, a membership site, or a donation platform, our WordPress module makes it easy to accept payments online. Download now and start accepting payments with ease!

See Setup Video: Watch Video Tutorial

WHMCS Module

Integrate our payment gateway seamlessly into your WHMCS setup. With our module, you can easily accept payments from your customers, manage invoices, and track transactions effortlessly. Get started with just a few clicks!

SMM Panel Module

Enhance your SMM panel with our payment gateway integration module. Streamline the payment process for your social media marketing services and provide a seamless experience for your clients. Download the module now and take your SMM panel to the next level!

Sketchware SWB Project

Easily integrate our payment gateway into your Android apps created with Sketchware. Download the ready-to-use SWB project file and connect your API credentials in minutes.

See Setup Video: Video Tutorial

Android Studio Module (Java / Kotlin)

Easily integrate our automated payment gateway into your native Android applications built with Android Studio. The module provides a ready-to-use Gradle library module (:paymentgateway), in-app secure WebView with automatic callback interception, external app intent handlers (bKash, Nagad, Rocket, Upay, banking apps), and a complete sample demo application.

See Setup Video: Video Tutorial

ইন্টিগ্রেশন কোড ও ব্যবহারের স্যাম্পল দেখতে উপরের Sample Request (Integration Tab) এ যান।

Mobile App

Download our official Android merchant application to monitor your transactions, receive instant payment notifications, and manage accounts on the go.

See Setup Video: Video Tutorial