# Introduction

Guide for user, merchant and developer

Merchant or developer can generate multiple API credentials through SecurePay Apps (<https://sandbox.securepay.my/apps/interfaces>). There are 3 type of credential values.


# API


# Introduction

Guide for merchant and developer

## Environments

SecurePay have two environments:

| Environment | Endpoint URL                       |
| ----------- | ---------------------------------- |
| Sandbox     | <https://sandbox.securepay.my/api> |
| Production  | <https://securepay.my/api>         |

## Credentials

There are 3 types of credential values&#x20;

| Type           | Format                                                           |
| -------------- | ---------------------------------------------------------------- |
| API UID        | 2aaa1633-e63f-4371-9b85-91d936aa56a1                             |
| Auth Token     | ZyUfF8EmyabcMWPcaocX                                             |
| Checksum Token | 159026b3b7348e2390e5a2e7a1c8466073db239c1e6800b8c27e36946b1f8713 |

{% hint style="info" %}
Merchant can generate multiple API credential.
{% endhint %}

## API Credentials

![API credentials from SecurePay dashboard](/files/-MKSwjrme80ReF3XzCbw)


# Validate

Validate the merchant credentials

## Endpoint URL&#x20;

| Environment | URL                                                      | Method |
| ----------- | -------------------------------------------------------- | ------ |
| Sandbox     | <https://sandbox.securepay.my/api/v1/merchants/validate> | Post   |
| Production  | <https://securepay.my/api/v1/merchants/validate>         | Post   |

## Credentials

There are 3 types of credential values&#x20;

| Type           | Format                                                           |
| -------------- | ---------------------------------------------------------------- |
| API UID        | 2aaa1633-e63f-4371-9b85-91d936aa56a1                             |
| Auth Token     | ZyUfF8EmyabcMWPcaocX                                             |
| Checksum Token | 159026b3b7348e2390e5a2e7a1c8466073db239c1e6800b8c27e36946b1f8713 |

## API Credentials&#x20;

![API credentials from SecurePay dashboard](/files/-MKSwjrme80ReF3XzCbw)

## Example command

```
curl -d checksum_token={checksum_token} -u {api_uid}:{auth_token} https://sandbox.securepay.my/api/v1/merchants/validate 
```

```
curl -d checksum_token=159026b3b7338e2390e5a2e7a1c8466073db259c1e6800b8c27e36946b1f8713 -u 2aaa1633-e63f-4371-9b85-91d936aa56a1:ZyUfF8EmyabcMWPcaocB https://sandbox.securepay.my/api/v1/merchants/validate 
```

## Result

Invalid token will return 401 Unauthorized

```
{"error":"Unauthorized. Invalid or expired token."}
```

Verified token will return 200&#x20;

```
{"credential":true,"api_name":"Sandbox Test1","merchant_name":"DNSVAULT SDN BHD"}
```


# Merchant


# Bank List

Guide for merchant. Open bank list

## B2C (Retail Banking) Endpoint URL

Becoming a super hero is a fairly straight forward process:

| Environment | URL                                                    | Method |
| ----------- | ------------------------------------------------------ | ------ |
| Sandbox     | <https://sandbox.securepay.my/api/public/v1/banks/b2c> | GET    |
| Production  | <https://securepay.my/api/public/v1/banks/b2c>         | GET    |

Getting bank list

{% embed url="<https://sandbox.securepay.my/api/public/v1/banks/b2c>" %}

Getting online and offline only

{% embed url="<https://sandbox.securepay.my/api/public/v1/banks/b2c?status=online>" %}

{% embed url="<https://sandbox.securepay.my/api/public/v1/banks/b2c?status=offline>" %}

## B2B (Corporate Banking) Endpoint URL

| Environment | URL                                                    | Method |
| ----------- | ------------------------------------------------------ | ------ |
| Sandbox     | <https://sandbox.securepay.my/api/public/v1/banks/b2b> | GET    |
| Production  | <https://securepay.my/api/public/v1/banks/b2b>         | GET    |

Getting bank list

{% embed url="<https://sandbox.securepay.my/api/public/v1/banks/b2b>" %}

Getting online and offline only

{% embed url="<https://sandbox.securepay.my/api/public/v1/banks/b2b?status=online>" %}

{% embed url="<https://sandbox.securepay.my/api/public/v1/banks/b2b?status=offline>" %}


# FPX Payment

For merchant

## Endpoint URL&#x20;

| Environment | URL                                            | Method |
| ----------- | ---------------------------------------------- | ------ |
| Sandbox     | <https://sandbox.securepay.my/api/v1/payments> | Post   |
| Production  | <https://securepay.my/api/v1/payments>         | Post   |

## Credentials

Using authentication parameter below:

|                                          |                                                                  |
| ---------------------------------------- | ---------------------------------------------------------------- |
| uid (Merchant API UID)                   | 2aaa1633-e63f-4371-9b85-91d936aa56a1                             |
| token (Merchant API Auth Token)          | ZyUfF8EmyabcMWPcaocX                                             |
| Checksum Token (Merchant Checksum Token) | 159026b3b7348e2390e5a2e7a1c8466073db239c1e6800b8c27e36946b1f8713 |

## API Credentials

![](/files/-MKSwjrme80ReF3XzCbw)

## Request Parameters

| Parameter            | Description                                                                                                                                          | Condition  | Example                                                                                                                                                                                                                 |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| order\_number        | Unique order number generated by your end for reference.                                                                                             | compulsory | 20200425132755                                                                                                                                                                                                          |
| buyer\_name          | Valid buyer full name in one line.                                                                                                                   | compulsory | AHMAD AMSYAR MOHD ALI                                                                                                                                                                                                   |
| buyer\_email         | Valid buyer email address for status update                                                                                                          | compulsory | <amsyar@gmail.com>                                                                                                                                                                                                      |
| buyer\_phone         | Valid buyer phone number.                                                                                                                            | compulsory | +60123121678                                                                                                                                                                                                            |
| transaction\_amount  | Amount format: 100.20 , 1000.00, 7000.30                                                                                                             | compulsory | 1540.40                                                                                                                                                                                                                 |
| product\_description | <p></p><p>Meaningful Product Description e.g.</p><p>●  Payment for order number 123</p><p>●  Payment for vintage table part #89782</p>               | compulsory | Payment for order no. 20200425132755                                                                                                                                                                                    |
| callback\_url        | Server to server. Securepay platform will post the payment status.                                                                                   | optional   |                                                                                                                                                                                                                         |
| redirect\_url        | Browser to browser, Securepay platform will post to the endpoint browser.                                                                            | optional   |                                                                                                                                                                                                                         |
| checksum             | Signed strings for verification.                                                                                                                     | compulsory | 2cb338beae0859....                                                                                                                                                                                                      |
| token                | API Token.                                                                                                                                           | compulsory | ZyUfF8Emy....                                                                                                                                                                                                           |
| params               | Send  up to 18  values or parameters e.g: reference1\_label and reference1 .. reference18\_label and reference18                                     | optional   | "params": {"reference1\_label" : "Size", "reference1" : "XL", "reference2\_label" : "IC No" , reference2 : "890323035586" }                                                                                             |
| redirect\_post       | Auto redirect to endpoint page.                                                                                                                      | optional   | true                                                                                                                                                                                                                    |
| shipping\_address    | Shipping address                                                                                                                                     | optional   | "shipping\_address": {"contact\_name":"John Doe John Kay", "contact\_phone\_number":"0133121999", "line1":"JLN UNGGUL 14/12","line2":"Bukit Harimau Belang", "postcode":"46000", "city":"Shah Alam","state":"Selangor"} |
| billing\_address     | Billing address                                                                                                                                      | optional   | "billing\_address": {"contact\_name":"John Doe John Kay", "contact\_phone\_number":"0133121999", "line1":"JLN UNGGUL 14/12","line2":"Bukit Harimau Belang", "postcode":"46000", "city":"Shah Alam","state":"Selangor"}  |
| buyer\_bank\_code    | Bank code generated from the banks list                                                                                                              | Optional   | MBB0228                                                                                                                                                                                                                 |
| model                | If not specify the platform will use B2C as default model. If using B2B1, set the model to B2B1. The FPX bank list also need to match with the model | optional   | B2C or B2B1                                                                                                                                                                                                             |
| fpx\_bank\_selection | If using securepay page for bank selection page. The bank selection can be displayed as dropdown or grid                                             | optional   | dropdown or grid                                                                                                                                                                                                        |
| cancel\_url          | SecurePay page for bank selection. If set the cancel URL. Button cancel will appear.                                                                 | optional   | <p>e.g: </p><p><https://yourdom.com/securepay>\_<em>cancel?order\_</em>number=123123</p><p></p>                                                                                                                         |
| timeout\_url         | SecurePay page for bank selection. if set the timeout URL. The page will timeout within 3 minutes                                                    | optional   | <p>e.g: </p><p><https://yourdom.com/securepay_timeout><em>?order\_</em>number=123123</p>                                                                                                                                |

B2C or B2B1 please set on the API settings inside SecurePay Apps. Other settings also can be set at the settings page.

#### API settings page

![](/files/-Mchs7s3X1q46UdDQM3H)

#### SecurePay bank selection page&#x20;

![](/files/-MchsQKy6hn5Nx4AB69-)

#### Grid bank selection

![](/files/-MchszsU87Tq9FLJlByQ)

## Generate Checksum

Only these parameters are needed to generate checksum:\
\
buyer\_email|buyer\_name|buyer\_phone|callback\_url|order\_number|product\_description|redirect\_url|transaction\_amount|uid<br>

* [ ] Arrange the parameter variables in ascending order as below (including API uid)

```

buyer_email|buyer_name|buyer_phone|callback_url|order_number|product_description|redirect_url|transaction_amount|uid 

```

* [ ] Construct the parameter values string based on the position above.

```

amsyar@gmail.com|AHMAD AMSYAR MOHD ALI|+60123121678||20200425132755|Payment for order no 20200425132755||1540.40|2aaa1633-e63f-4371-9b85-91d936aa56a1

```

* [ ] Sign the string with checksum token using HMAC SHA256

{% tabs %}
{% tab title="Ruby" %}

```ruby

string = "amsyar@gmail.com|AHMAD AMSYAR MOHD ALI|+60123121678||20200425132755|Payment for order no 20200425132755||1540.40|2aaa1633-e63f-4371-9b85-91d936aa56a1​"
checksum_token = "​159026b3b7348e2390e5a2e7a1c8466073db239c1e6800b8c27e36946b1f8713​"
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), checksum_token, string)

```

{% endtab %}

{% tab title="PHP" %}

```php

$string = ​"​amsyar@gmail.com|AHMAD AMSYAR MOHD ALI|+60123121678||20200425132755|Payment for order no 20200425132755||1540.40|2aaa1633-e63f-4371-9b85-91d936aa56a1​"
$checksum_token = ​"159026b3b7348e2390e5a2e7a1c8466073db239c1e6800b8c27e36946b1f8713​"
$sign = hash_hmac('sha256', $string, $checksum_token)

```

{% endtab %}
{% endtabs %}

* [ ] Generated checksum

**75b54e403151b1e9b413df8ce5c426ef0dbbc9adcec58b8f5dd5c9c5c6b78844**

## Post the parameters

Sending all parameters in request parameter table to the payment URL by using post method

&#x20;

## Sample Codes

{% tabs %}
{% tab title="PHP" %}

```php
<?php

//Author: amir@p.my, amir@securepay.my
//Org   : SecurePay
//We need more contribution on sample codes. Email me.

if(isset($_POST['order_number']))
{
//Change with your token	
$uid = '9097b595-b77a-4321-94c0-0a6d323b5252';
$checksum_token = 'f4e4f07afb72a56fc6681d652713522436b50f087306efec39ab7d1be5b8c684';
$auth_token = '5BXhsTmVmRBKkg6xizNB';
$url = 'https://sandbox.securepay.my/api/v1/payments';

#$_POST['order_number'] = '20200425132755';
#$_POST['buyer_name'] = 'AHMAD AMSYAR MOHD ALI';
#$_POST['buyer_email'] = 'amsyar@gmail.com';
#$_POST['buyer_phone'] = '+60123121678';
#$_POST['transaction_amount'] = '10.00';
#$_POST['product_description'] = 'Payment for order no 20200425132755';
#$_POST['callback_url'] = "";
#$_POST['redirect_url'] = "";
#$_POST['token'] = $auth_token;
#$_POST['redirect_post'] = "true";

$order_number = $_POST['order_number'];
$buyer_name = $_POST['buyer_name'];
$buyer_phone = $_POST['buyer_phone'];
$buyer_email = $_POST['buyer_email'];
$product_description = $_POST['product_description'];
$transaction_amount = $_POST['transaction_amount'];
$callback_url = $_POST['callback_url'];
$redirect_url = $_POST['redirect_url'];
$redirect_post = "true";
if(isset($_POST['buyer_bank_code'])) { 
	$buyer_bank_code = $_POST['buyer_bank_code']; 
}




//buyer_email|buyer_name|buyer_phone|callback_url|order_number|product_description|redirect_url|transaction_amount|uid 

$string = $buyer_email."|".$buyer_name."|".$buyer_phone."|".$callback_url."|".$order_number."|".$product_description."|".$redirect_url ."|".$transaction_amount."|".$uid;

#echo $string . "\n";
#string = "amsyar@gmail.com|AHMAD AMSYAR MOHD ALI|+60123121678||20200425132755|Payment for order no 20200425132755||1540.40|5d80cc30-1a42-4f9f-9d6b-a69db5d26b01​"


#$string = "amsyar@gmail.com|AHMAD AMSYAR MOHD ALI|0123121678||20200425132755|Payment for order no 20200425132755||1540.40|2aaa1633-e63f-4371-9b85-91d936aa56a1​";
#$checksum_token = "159026b3b7348e2390e5a2e7a1c8466073db239c1e6800b8c27e36946b1f8713​";

$sign = hash_hmac('sha256', $string, $checksum_token);

#echo $sign . "\n";

//
//echo $sign

//$hashed_string = hash_hmac($checksum_token.urldecode($_POST['product_description']).urldecode($_POST['transaction_amount']).urldecode($_POST['order_number']));

if(isset($_POST['buyer_bank_code'])) {  

$post_data = "buyer_name=".urlencode($buyer_name)."&token=". urlencode($auth_token) 
."&callback_url=".urlencode($callback_url)."&redirect_url=". urlencode($redirect_url) . 
"&order_number=".urlencode($order_number)."&buyer_email=".urlencode($buyer_email).
"&buyer_phone=".urlencode($buyer_phone)."&transaction_amount=".urlencode($transaction_amount).
"&product_description=".urlencode($product_description)."&redirect_post=".urlencode($redirect_post).
"&checksum=".urlencode($sign)."&buyer_bank_code=".urlencode($buyer_bank_code);
}
else
{
$post_data = "buyer_name=".urlencode($buyer_name)."&token=". urlencode($auth_token) 
."&callback_url=".urlencode($callback_url)."&redirect_url=". urlencode($redirect_url) . 
"&order_number=".urlencode($order_number)."&buyer_email=".urlencode($buyer_email).
"&buyer_phone=".urlencode($buyer_phone)."&transaction_amount=".urlencode($transaction_amount).
"&product_description=".urlencode($product_description)."&redirect_post=".urlencode($redirect_post).
"&checksum=".urlencode($sign);	
}


#echo $post_data. "\n";

// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_exec($ch);

$output = curl_exec($ch);

echo $output;

}




#header('Location: ' + $output);
#exit();

#curl_close($ch);

$order_number = rand(1111111111,9999999999);

$json = file_get_contents('https://sandbox.securepay.my/api/public/v1/banks/b2c');
$obj = json_decode($json, true);
//echo $obj->access_token;
//$obj->fpx_bankList

//print_r($obj['fpx_bankList']);

$options = "";

foreach ($obj['fpx_bankList'] as $value) {
	if($value['status_format2'])
	{
	    $options .= "<option value=". $value['code'] . ">" . $value['name'] . "</option>";
	}
	else
	{
		$options .= "<option value=". $value['code'] . " disabled>" . $value['name'] . " (offline)</option>";
	}
	//echo $value['code'];
}
 
//print_r($obj->fpx_bankList);

?>
<h1>SecurePay sample code for PHP</h1>
<hr> 
<h3>Form without bank list</h3>
<form action="" method="post">
  <label for="fname">Full name:</label><br>
  <input type="text" id="fname" name="buyer_name" value="John Doe"><br>
  <label for="lname">Email:</label><br>
  <input type="text" id="lname" name="buyer_email" value="john@gmail.com"><br>
  <label for="lname">Phone No:</label><br>
  <input type="text" id="lname" name="buyer_phone" value="+60129997979"><br>
  <label for="lname">Order number:</label><br>
  <input type="text" id="lname" name="order_number" value="<?=$order_number;?>"><br>
  <label for="lname">Descriptions:</label><br>
  <input type="text" id="lname" name="product_description" value="Payment for order no. <?=$order_number;?>"><br>
  
  <label for="lname">Callback URL:</label><br>
  <input type="text" id="lname" name="callback_url" value="" placeholder="Optional"><br>
  
  <label for="lname">Redirect URL:</label><br>
  <input type="text" id="lname" name="redirect_url" value="" placeholder="Optional"><br>
  
  <label for="lname">Amount:</label><br>
  <input type="text" id="lname" name="transaction_amount" value="199"><br>
  <br>
  <input type="submit" value="Submit">
</form>

<hr> 

<h3>Form with bank list</h3>


<form action="" method="post">
  <label for="fname">Full name:</label><br>
  <input type="text" id="fname" name="buyer_name" value="John Doe"><br>
  <label for="lname">Email:</label><br>
  <input type="text" id="lname" name="buyer_email" value="john@gmail.com"><br>
  <label for="lname">Phone No:</label><br>
  <input type="text" id="lname" name="buyer_phone" value="+60129997979"><br>
  <label for="lname">Order number:</label><br>
  <input type="text" id="lname" name="order_number" value="<?=$order_number;?>"><br>
  <label for="lname">Descriptions:</label><br>
  <input type="text" id="lname" name="product_description" value="Payment for order no. <?=$order_number;?>"><br>
  <label for="lname">Amount:</label><br>
  <input type="text" id="lname" name="transaction_amount" value="199"><br>
  <label for="lname">Callback URL:</label><br>
  <input type="text" id="lname" name="callback_url" value="" placeholder="Optional"><br>
  
  <label for="lname">Redirect URL:</label><br>
  <input type="text" id="lname" name="redirect_url" value="" placeholder="Optional"><br>
  
  <label for="lname">Select bank:</label><br>
  <select id="buyer_bank_code" name="buyer_bank_code"><?=$options?></select><br>
  
  <br>
  <input type="submit" value="Submit">
</form>
```

{% endtab %}

{% tab title="Rails" %}

```
```

{% endtab %}
{% endtabs %}

##


# Partner

Partner

Any marketplace provider and merchant that sign up as SecurePay Partner


# List

Below are our verified partners

## Shoppegram

{% hint style="success" %}
<https://docs.shoppegram.com/integration/payment-gateway/securepay>
{% endhint %}

{% embed url="<https://www.shoppegram.com/>" %}
Shoppegram
{% endembed %}

## Ordersini

{% hint style="success" %}
<https://ordersini.blog/integration-securepay-di-dalam-ordersini-memudahkan-proses-jual-beli-online/>
{% endhint %}

{% embed url="<https://ordersini.com>" %}
Ordersini
{% endembed %}

## Kiah Store

{% embed url="<https://www.kiah.store>" %}
Kiah Store
{% endembed %}


# Bank List

Guide for partner. Only partner can access bank list.

## Credentials

Using basic authentication with below information:

|                           |                                      |
| ------------------------- | ------------------------------------ |
| Username (API UID)        | 2aaa1633-e63f-4371-9b85-91d936aa56a1 |
| Password (API Auth Token) | ZyUfF8EmyabcMWPcaocX                 |

## B2C (Retail Banking) Endpoint URL

Becoming a super hero is a fairly straight forward process:

| Environment | URL                                             | Method |
| ----------- | ----------------------------------------------- | ------ |
| Sandbox     | <https://sandbox.securepay.my/api/v1/banks/b2c> | GET    |
| Production  | <https://securepay.my/api/v1/banks/b2c>         | GET    |

## B2B1 (Corporate Banking) Endpoint URL

Merchant need to enable this module

| Environment | URL                                              | Method |
| ----------- | ------------------------------------------------ | ------ |
| Sandbox     | <https://sandbox.securepay.my/api/v1/banks/b2b1> | GET    |
| Production  | <https://securepay.my/api/v1/banks/b2b1>         | GET    |

{% hint style="info" %}
&#x20;Super-powers are granted randomly so please submit an issue if you're not happy with yours.
{% endhint %}

Once you're strong enough, save the world:

## API

## Banks list

<mark style="color:blue;">`GET`</mark> `https://sandbox.securepay.my/api/v1/banks/b2c`

Query banks list

{% tabs %}
{% tab title="200 " %}

```
{
    "VerifySign": true,
    "category": "fpx",
    "model": "B2C",
    "mode": "staging",
    "fpx_bankList": [
        {
            "name": "AGRO01",
            "code": "AGRO01",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "Affin B2C - Test ID",
            "code": "ABB0234",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "Affin Bank",
            "code": "ABB0233",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "Alliance Bank (Personal)",
            "code": "ABMB0212",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "AmBank",
            "code": "AMBB0209",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "BSN",
            "code": "BSN0601",
            "status_format1": "offline",
            "status_format2": false
        },
        {
            "name": "Bank Islam",
            "code": "BIMB0340",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "Bank Muamalat",
            "code": "BMMB0341",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "Bank Rakyat",
            "code": "BKRM0602",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "CIMB Clicks",
            "code": "BCBB0235",
            "status_format1": "offline",
            "status_format2": false
        },
        {
            "name": "Citibank",
            "code": "CIT0219",
            "status_format1": "offline",
            "status_format2": false
        },
        {
            "name": "HSBC Bank",
            "code": "HSBC0223",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "Hong Leong Bank",
            "code": "HLB0224",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "KFH",
            "code": "KFH0346",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "MBB0228",
            "code": "MBB0228",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "Maybank2U",
            "code": "MB2U0227",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "OCBC Bank",
            "code": "OCBC0229",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "Public Bank",
            "code": "PBB0233",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "RHB Bank",
            "code": "RHB0218",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "SBI Bank A",
            "code": "TEST0021",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "SBI Bank B",
            "code": "TEST0022",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "SBI Bank C",
            "code": "TEST0023",
            "status_format1": "online",
            "status_format2": true
        },
        {
            "name": "Standard Chartered",
            "code": "SCB0216",
            "status_format1": "offline",
            "status_format2": false
        },
        {
            "name": "UOB Bank",
            "code": "UOB0226",
            "status_format1": "offline",
            "status_format2": false
        },
        {
            "name": "UOB Bank - Test ID",
            "code": "UOB0229",
            "status_format1": "offline",
            "status_format2": false
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Curl

Sample Query

```bash
curl -u 2aaa1633-e63f-4371-9b85-91d936aa56a1:ZyUfF8EmyabcMWPcaocX -i -H 'Accept:application/json' https://sandbox.securepay.my/api/v1/banks/b2c
```

Sample Response

```bash
{"VerifySign":true,"category":"fpx","model":"B2C","mode":"staging","fpx_bankList":[{"name":"AGRO01","code":"AGRO01","status_format1":"online","status_format2":true},{"name":"Affin B2C - Test ID","code":"ABB0234","status_format1":"online","status_format2":true},{"name":"Affin Bank","code":"ABB0233","status_format1":"online","status_format2":true},{"name":"Alliance Bank (Personal)","code":"ABMB0212","status_format1":"online","status_format2":true},{"name":"AmBank","code":"AMBB0209","status_format1":"online","status_format2":true},{"name":"BSN","code":"BSN0601","status_format1":"offline","status_format2":false},{"name":"Bank Islam","code":"BIMB0340","status_format1":"online","status_format2":true},{"name":"Bank Muamalat","code":"BMMB0341","status_format1":"online","status_format2":true},{"name":"Bank Rakyat","code":"BKRM0602","status_format1":"online","status_format2":true},{"name":"CIMB Clicks","code":"BCBB0235","status_format1":"offline","status_format2":false},{"name":"Citibank","code":"CIT0219","status_format1":"offline","status_format2":false},{"name":"HSBC Bank","code":"HSBC0223","status_format1":"online","status_format2":true},{"name":"Hong Leong Bank","code":"HLB0224","status_format1":"online","status_format2":true},{"name":"KFH","code":"KFH0346","status_format1":"online","status_format2":true},{"name":"MBB0228","code":"MBB0228","status_format1":"online","status_format2":true},{"name":"Maybank2U","code":"MB2U0227","status_format1":"online","status_format2":true},{"name":"OCBC Bank","code":"OCBC0229","status_format1":"online","status_format2":true},{"name":"Public Bank","code":"PBB0233","status_format1":"online","status_format2":true},{"name":"RHB Bank","code":"RHB0218","status_format1":"online","status_format2":true},{"name":"SBI Bank A","code":"TEST0021","status_format1":"online","status_format2":true},{"name":"SBI Bank B","code":"TEST0022","status_format1":"online","status_format2":true},{"name":"SBI Bank C","code":"TEST0023","status_format1":"online","status_format2":true},{"name":"Standard Chartered","code":"SCB0216","status_format1":"offline","status_format2":false},{"name":"UOB Bank","code":"UOB0226","status_format1":"offline","status_format2":false},{"name":"UOB Bank - Test ID","code":"UOB0229","status_format1":"offline","status_format2":false}]}
```

| Variables                       | Values                | Description                                                                      |
| ------------------------------- | --------------------- | -------------------------------------------------------------------------------- |
| VerifySign                      | true or false         | Verify data source only accept true value. false might be bogus, please discard. |
| Category                        | fpx                   | Default is fpx                                                                   |
| Model                           | B2C or B2B1           | Identify which model                                                             |
| Mode                            | staging or production | Current mode                                                                     |
| fpx\_bankList - name            |                       | Bank name                                                                        |
| fpx\_bankList - code            |                       | Bank Code                                                                        |
| fpx\_bankList - status\_format1 | online or offline     | Current bank status in word online or offline                                    |
| fpx\_bankList - status\_format2 | true or false         | Current bank status in boolean true for online and vice versa                    |

{% tabs %}
{% tab title="Ruby" %}

```ruby
We need your super power. Please help us by share the code, email us amir@securepay.my
```

{% endtab %}

{% tab title="PHP" %}

```
We need your super power. Please help us by share the code, email us amir@securepay.my
```

{% endtab %}
{% endtabs %}


# FPX Payment

For partner

Preferred partner can have their own ID for processing payment. Merchant will use their own API credentials as usual.&#x20;

## Endpoint URL&#x20;

| Environment | URL                                            | Method |
| ----------- | ---------------------------------------------- | ------ |
| Sandbox     | <https://sandbox.securepay.my/api/v1/payments> | POST   |
| Production  | <https://securepay.my/api/v1/payments>         | POST   |

## Credentials

Using authentication parameter below:

|                                 |                                                                  |
| ------------------------------- | ---------------------------------------------------------------- |
| uid (Merchant API UID)          | 2aaa1633-e63f-4371-9b85-91d936aa56a1                             |
| token (Merchant API Auth Token) | ZyUfF8EmyabcMWPcaocX                                             |
| Checksum Token                  | 159026b3b7348e2390e5a2e7a1c8466073db239c1e6800b8c27e36946b1f8713 |

Partner may have many merchants. The uid and token are merchant credentials, partner only need to supply their partner\_uid only. While merchant need to use theirs. In some case, partner also can be a merchant.&#x20;

## API Credentials

![](/files/-MKSwjrme80ReF3XzCbw)

## Partner UID

Every partner will be issued one or more partner UID (partner\_uid). SecurePay will identified partner account by using this identifier. &#x20;

## Request Parameters

| Parameter            | Description                                                                                                                                          | Condition  | Example                                                                                                                                                                                                                |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| order\_number        | Unique order number generated by merchant end for reference.                                                                                         | Compulsory | 20200425132755                                                                                                                                                                                                         |
| buyer\_name          | Valid buyer full name in one line.                                                                                                                   | Compulsory | AHMAD AMSYAR MOHD ALI                                                                                                                                                                                                  |
| buyer\_email         | Valid buyer email address for status update                                                                                                          | Compulsory | <amsyar@gmail.com>                                                                                                                                                                                                     |
| buyer\_phone         | Valid buyer phone number e.g: +60123121989                                                                                                           | Compulsory | +60123121678                                                                                                                                                                                                           |
| transaction\_amount  | Amount format: 100.20 , 1000.00, 7000.30                                                                                                             | Compulsory | 1540.40                                                                                                                                                                                                                |
| product\_description | <p>Meaningful Product Description e.g.</p><ul><li>Payment for order number 123</li><li>Payment for vintage table part #89782</li></ul>               | Compulsory | Payment for order no 20200425132755                                                                                                                                                                                    |
| checksum             | Signed strings for verification.                                                                                                                     | Compulsory | 2cb338beae0859e.......                                                                                                                                                                                                 |
| token                | API token                                                                                                                                            | Compulsory | ZyUfF8EmyabcMWPcaocX                                                                                                                                                                                                   |
| callback\_url        | Server to server. Securepay platform will post the payment status.                                                                                   | Optional   |                                                                                                                                                                                                                        |
| redirect\_url        | Browser to browser, Securepay platform will post to the endpoint browser.                                                                            | Optional   |                                                                                                                                                                                                                        |
| partner\_uid         | Partner UID value                                                                                                                                    | Compulsory | c52853e0-24d6 .....                                                                                                                                                                                                    |
| uid                  | API UID                                                                                                                                              | Compulsory | 2aaa1633-e63f ......                                                                                                                                                                                                   |
| redirect\_post       | Auto redirect to endpoint page.                                                                                                                      | Optional   | true                                                                                                                                                                                                                   |
| params               | Send  up to 18  values or parameters e.g: reference1\_label and reference1 .. reference18\_label and reference18                                     | optional   | "params": {"reference1\_label" : "Size", "reference1" : "XL", "reference2\_label" : "IC No" , "reference2" : "830102035587"                                                                                            |
| buyer\_bank\_code    | Bank code generated from the banks list                                                                                                              | Optional   | MBB0228                                                                                                                                                                                                                |
| shipping\_address    | Shipping address                                                                                                                                     | optional   | "shipping\_address":{"contact\_name":"John Doe John Kay", "contact\_phone\_number":"0133121999", "line1":"JLN UNGGUL 14/12","line2":"Bukit Harimau Belang", "postcode":"46000", "city":"Shah Alam","state":"Selangor"} |
| billing\_address     | Billing address                                                                                                                                      | optional   | "billing\_address":{"contact\_name":"John Doe John Kay", "contact\_phone\_number":"0133121999", "line1":"JLN UNGGUL 14/12","line2":"Bukit Harimau Belang", "postcode":"46000", "city":"Shah Alam","state":"Selangor"}  |
| model                | If not specify the platform will use B2C as default model. If using B2B1, set the model to B2B1. The FPX bank list also need to match with the model | optional   | B2C or B2B1                                                                                                                                                                                                            |
| fpx\_bank\_selection | If using securepay page for bank selection page. The bank selection can be displayed as dropdown or grid                                             | optional   | dropdown or grid                                                                                                                                                                                                       |
| cancel\_url          | SecurePay page for bank selection. If set the cancel URL. Button cancel will appear.                                                                 | optional   | <p>e.g: </p><p><https://yourdom.com/securepay>\_<em>cancel?order\_</em>number=123123</p><p></p>                                                                                                                        |
| timeout\_url         | SecurePay page for bank selection. if set the timeout URL. The page will timeout within 3 minutes                                                    | optional   | <p>e.g: </p><p><https://yourdom.com/securepay_timeout><em>?order\_</em>number=123123</p>                                                                                                                               |

B2C or B2B1 please set on the API settings inside SecurePay Apps. Other settings also can be set at the settings page.

#### API settings page

![](/files/-Mchs7s3X1q46UdDQM3H)

#### SecurePay bank selection page&#x20;

![](/files/-MchsQKy6hn5Nx4AB69-)

#### Grid bank selection

![](/files/-MchszsU87Tq9FLJlByQ)

## Generate Checksum

Below is how to generate checksum parameter

* [ ] Arrange the parameter variables in ascending order as below (except partner\_uid)

```bash
buyer_email|buyer_name|buyer_phone|callback_url|order_number|product_description|redirect_url|transaction_amount|uid
```

* [ ] Construct the parameter values string based on the position in point no 1.

```bash
amsyar@gmail.com|AHMAD AMSYAR MOHD ALI|+60123121678||20200425132755|Payment for order no 20200425132755||1540.40|2aaa1633-e63f-4371-9b85-91d936aa56a1S
```

* [ ] Sign the string with checksum token using HMAC256

{% tabs %}
{% tab title="Ruby" %}

```ruby
string = "​amsyar@gmail.com|AHMAD AMSYAR MOHD ALI|+60123121678||20200425132755|Payment for order no 20200425132755||1540.40|2aaa1633-e63f-4371-9b85-91d936aa56a1​"
checksum_token = "159026b3b7348e2390e5a2e7a1c8466073db239c1e6800b8c27e36946b1f8713​"
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), checksum_token, string)
=> "5475e02fc8c9443c055eef6bca36b5b5b7999e36c14d9890c45409ea56c53942" 

```

{% endtab %}

{% tab title="PHP" %}

```php
$string = "amsyar@gmail.com|AHMAD AMSYAR MOHD ALI|0123121678||20200425132755|Payment for order no 20200425132755||1540.40|2aaa1633-e63f-4371-9b85-91d936aa56a1​"
$checksum_token = ​"​159026b3b7348e2390e5a2e7a1c8466073db239c1e6800b8c27e36946b1f8713​"
$sign = hash_hmac('sha256', $string, $checksum_token)
=> "5475e02fc8c9443c055eef6bca36b5b5b7999e36c14d9890c45409ea56c53942" 

```

{% endtab %}
{% endtabs %}

Generate checksum from the above example:

&#x20;**75b54e403151b1e9b413df8ce5c426ef0dbbc9adcec58b8f5dd5c9c5c6b78844**

{% hint style="info" %}
Sending all parameters in Request Parameter Table to the payment URL by using post method
{% endhint %}

## Sample Codes

{% tabs %}
{% tab title="PHP" %}

```bash
<?php

//Author: amir@p.my, amir@securepay.my
//Org   : SecurePay
//We need more contribution on sample codes. Email me.

if(isset($_POST['order_number']))
{
//Change with your token	
$uid = '9097b595-b77a-4321-94c0-0a6d323b5252';
$checksum_token = 'f4e4f07afb72a56fc6681d652713522436b50f087306efec39ab7d1be5b8c684';
$auth_token = '5BXhsTmVmRBKkg6xizNB';
$partner_uid = 'ebea23429-024a-4803-8968-cca40814b234';
$url = 'https://sandbox.securepay.my/api/v1/payments';

#$_POST['order_number'] = '20200425132755';
#$_POST['buyer_name'] = 'AHMAD AMSYAR MOHD ALI';
#$_POST['buyer_email'] = 'amsyar@gmail.com';
#$_POST['buyer_phone'] = '+60123121678';
#$_POST['transaction_amount'] = '10.00';
#$_POST['product_description'] = 'Payment for order no 20200425132755';
#$_POST['callback_url'] = "";
#$_POST['redirect_url'] = "";
#$_POST['token'] = $auth_token;
#$_POST['redirect_post'] = "true";

$order_number = $_POST['order_number'];
$buyer_name = $_POST['buyer_name'];
$buyer_phone = $_POST['buyer_phone'];
$buyer_email = $_POST['buyer_email'];
$product_description = $_POST['product_description'];
$transaction_amount = $_POST['transaction_amount'];
$callback_url = $_POST['callback_url'];
$redirect_url = $_POST['redirect_url'];
$redirect_post = "true";
if(isset($_POST['buyer_bank_code'])) { 
	$buyer_bank_code = $_POST['buyer_bank_code']; 
}




//buyer_email|buyer_name|buyer_phone|callback_url|order_number|product_description|redirect_url|transaction_amount|uid 

$string = $buyer_email."|".$buyer_name."|".$buyer_phone."|".$callback_url."|".$order_number."|".$product_description."|".$redirect_url ."|".$transaction_amount."|".$uid;

#echo $string . "\n";
#string = "amsyar@gmail.com|AHMAD AMSYAR MOHD ALI|+60123121678||20200425132755|Payment for order no 20200425132755||1540.40|5d80cc30-1a42-4f9f-9d6b-a69db5d26b01​"


#$string = "amsyar@gmail.com|AHMAD AMSYAR MOHD ALI|0123121678||20200425132755|Payment for order no 20200425132755||1540.40|2aaa1633-e63f-4371-9b85-91d936aa56a1​";
#$checksum_token = "159026b3b7348e2390e5a2e7a1c8466073db239c1e6800b8c27e36946b1f8713​";

$sign = hash_hmac('sha256', $string, $checksum_token);

#echo $sign . "\n";

//
//echo $sign

//$hashed_string = hash_hmac($checksum_token.urldecode($_POST['product_description']).urldecode($_POST['transaction_amount']).urldecode($_POST['order_number']));

if(isset($_POST['buyer_bank_code'])) {  

$post_data = "buyer_name=".urlencode($buyer_name)."&token=". urlencode($auth_token) 
."&callback_url=".urlencode($callback_url)."&redirect_url=". urlencode($redirect_url) . 
"&order_number=".urlencode($order_number)."&buyer_email=".urlencode($buyer_email).
"&buyer_phone=".urlencode($buyer_phone)."&transaction_amount=".urlencode($transaction_amount).
"&product_description=".urlencode($product_description)."&redirect_post=".urlencode($redirect_post).
"&checksum=".urlencode($sign)."&buyer_bank_code=".urlencode($buyer_bank_code)."&partner_uid=".urlencode($partner_uid);
}
else
{
$post_data = "buyer_name=".urlencode($buyer_name)."&token=". urlencode($auth_token) 
."&callback_url=".urlencode($callback_url)."&redirect_url=". urlencode($redirect_url) . 
"&order_number=".urlencode($order_number)."&buyer_email=".urlencode($buyer_email).
"&buyer_phone=".urlencode($buyer_phone)."&transaction_amount=".urlencode($transaction_amount).
"&product_description=".urlencode($product_description)."&redirect_post=".urlencode($redirect_post).
"&checksum=".urlencode($sign)."&partner_uid=".urlencode($partner_uid);	
}


#echo $post_data. "\n";

// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_exec($ch);

$output = curl_exec($ch);

echo $output;

}




#header('Location: ' + $output);
#exit();

#curl_close($ch);

$order_number = rand(1111111111,9999999999);

$json = file_get_contents('https://sandbox.securepay.my/api/public/v1/banks/b2c');
$obj = json_decode($json, true);
//echo $obj->access_token;
//$obj->fpx_bankList

//print_r($obj['fpx_bankList']);

$options = "";

foreach ($obj['fpx_bankList'] as $value) {
	if($value['status_format2'])
	{
	    $options .= "<option value=". $value['code'] . ">" . $value['name'] . "</option>";
	}
	else
	{
		$options .= "<option value=". $value['code'] . " disabled>" . $value['name'] . " (offline)</option>";
	}
	//echo $value['code'];
}
 
//print_r($obj->fpx_bankList);

?>
<h1>SecurePay sample code for PHP</h1>
<hr> 
<h3>Form without bank list</h3>
<form action="" method="post">
  <label for="fname">Full name:</label><br>
  <input type="text" id="fname" name="buyer_name" value="John Doe"><br>
  <label for="lname">Email:</label><br>
  <input type="text" id="lname" name="buyer_email" value="john@gmail.com"><br>
  <label for="lname">Phone No:</label><br>
  <input type="text" id="lname" name="buyer_phone" value="+60129997979"><br>
  <label for="lname">Order number:</label><br>
  <input type="text" id="lname" name="order_number" value="<?=$order_number;?>"><br>
  <label for="lname">Descriptions:</label><br>
  <input type="text" id="lname" name="product_description" value="Payment for order no. <?=$order_number;?>"><br>
  
  <label for="lname">Callback URL:</label><br>
  <input type="text" id="lname" name="callback_url" value="" placeholder="Optional"><br>
  
  <label for="lname">Redirect URL:</label><br>
  <input type="text" id="lname" name="redirect_url" value="" placeholder="Optional"><br>
  
  <label for="lname">Amount:</label><br>
  <input type="text" id="lname" name="transaction_amount" value="199"><br>
  <br>
  <input type="submit" value="Submit">
</form>

<hr> 

<h3>Form with bank list</h3>


<form action="" method="post">
  <label for="fname">Full name:</label><br>
  <input type="text" id="fname" name="buyer_name" value="John Doe"><br>
  <label for="lname">Email:</label><br>
  <input type="text" id="lname" name="buyer_email" value="john@gmail.com"><br>
  <label for="lname">Phone No:</label><br>
  <input type="text" id="lname" name="buyer_phone" value="+60129997979"><br>
  <label for="lname">Order number:</label><br>
  <input type="text" id="lname" name="order_number" value="<?=$order_number;?>"><br>
  <label for="lname">Descriptions:</label><br>
  <input type="text" id="lname" name="product_description" value="Payment for order no. <?=$order_number;?>"><br>
  <label for="lname">Amount:</label><br>
  <input type="text" id="lname" name="transaction_amount" value="199"><br>
  <label for="lname">Callback URL:</label><br>
  <input type="text" id="lname" name="callback_url" value="" placeholder="Optional"><br>
  
  <label for="lname">Redirect URL:</label><br>
  <input type="text" id="lname" name="redirect_url" value="" placeholder="Optional"><br>
  
  <label for="lname">Select bank:</label><br>
  <select id="buyer_bank_code" name="buyer_bank_code"><?=$options?></select><br>
  
  <br>
  <input type="submit" value="Submit">
</form>
```

{% endtab %}

{% tab title="Rails" %}

```
```

{% endtab %}
{% endtabs %}


# Payment Session (beta)

Merchant or partner can create payment session and access the generated URL to perform payment collection


# Introduction

Guide for merchant and developer

## Environments

Payment Session has two environments:

| Environment | Endpoint URL                                     |
| ----------- | ------------------------------------------------ |
| Sandbox     | <https://sandbox.securepay.my/api/apis/payments> |
| Production  | <https://securepay.my/api/apis/payments>         |

## Credentials

There are 2 types of credential values&#x20;

| Type                  | Format                               |
| --------------------- | ------------------------------------ |
| API UID (username)    | 2aaa1633-e63f-4371-9b85-91d936aa56a1 |
| Auth Token (password) | ZyUfF8EmyabcMWPcaocX                 |

{% hint style="info" %}
Merchant can generate multiple API credential.
{% endhint %}

## API Credentials

![API credentials from SecurePay dashboard](/files/-MKSwjrme80ReF3XzCbw)


# Create Payment Session

Partner and Merchant will use their own API credentials as usual.&#x20;

## Credentials and Authentication

Using the authentication parameter below:

| username (Merchant API UID)        | 2aaa1633-e63f-4371-9b85-91d936aa56a1 |
| ---------------------------------- | ------------------------------------ |
| password (Merchant API Auth Token) | ZyUfF8EmyabcMWPcaocX                 |

To create a session. the merchant needs to use basic authentication

To send basic auth credentials with Curl, use the "-u login: password" command-line option. Curl automatically converts the login: password pair into a Base64-encoded string and adds the "Authorization: Basic \[token]" header to the request. In this Curl request with Basic Auth Credentials example, we send a request with basic authorization credentials&#x20;

`curl https://securepay.my/echo -u "login:password"`

## API Credentials

![](/files/-MKSwjrme80ReF3XzCbw)

## Partner UID

Every partner will be issued one or more partner UID (partner\_uid). SecurePay will identify partner accounts by using this identifier. &#x20;

## Request Parameters

Please use POST method. The only compulsory parameter is the transaction\_amount however merchants usually needs to supply **order number** in order to keep track record on their side. Your POST request will be returned in JSON format (later you can access payment\_url)

**Curl Request**

`curl -X POST https://sandbox.securepay.my/api/apis/payments -u 2aaa1633-e63f-4371-9b85-91d936aa56a1:ZyUfF8EmyabcMWPcaocX -d 'transaction_amount=200&order_number=231212&cancel_url=https://test.com'`

**Result**

{"payment\_url":"<https://sandbox.securepay.my/api/apis/GSHJD1664332374/payment\\_session","data":{"buyer\\_name":null,"buyer\\_email":null,"buyer\\_phone":null,"transaction\\_amount":"200.00","order\\_number":"231212","product\\_description":"Payment> for order no. 231212","slug":"GSHJD1664332374","callback\_url":null,"redirect\_url":null,"cancel\_url":"<https://test.com","timeout\\_url":null,"currency":"MYR","currency\\_amount":"200.00","partner\\_uid":null,"other\\_params":null,"created\\_at":"2022-09-28T10:32:54.087+08:00","updated\\_at":"2022-09-28T10:32:54.087+08:00"}>

The payment form can be accessed through payment\_url <https://sandbox.securepay.my/api/apis/GSHJD1664332374/payment\\_session>

**Payment Form (**<https://sandbox.securepay.my/api/apis/GSHJD1664332374/payment_session>**)**

<figure><img src="/files/6mhFg5O4mqjVFhvnI6EC" alt=""><figcaption><p>Generated page</p></figcaption></figure>

| Parameter            | Description                                                                                                                                                                                                                                                                                         | Condition  | Example                                                                                         |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ----------------------------------------------------------------------------------------------- |
| order\_number        | Unique order number generated by merchant end for reference.                                                                                                                                                                                                                                        | Optional   | 20200425132755                                                                                  |
| buyer\_name          | Valid buyer full name in one line.                                                                                                                                                                                                                                                                  | Optional   | AHMAD AMSYAR MOHD ALI                                                                           |
| buyer\_email         | Valid buyer email address for status update                                                                                                                                                                                                                                                         | Optional   | <amsyar@gmail.com>                                                                              |
| buyer\_phone         | Valid buyer phone number e.g: +60123121989                                                                                                                                                                                                                                                          | Optional   | +60123121678                                                                                    |
| transaction\_amount  | Amount format: 100.20 , 1000.00, 7000.30                                                                                                                                                                                                                                                            | Compulsory | 1540.40                                                                                         |
| product\_description | <p>Meaningful Product Description e.g.</p><ul><li>Payment for order number 123</li><li>Payment for vintage table part #89782</li></ul>                                                                                                                                                              | Optional   | Payment for order no 20200425132755                                                             |
| callback\_url        | Server to server. Securepay platform will post the payment status.                                                                                                                                                                                                                                  | Optional   |                                                                                                 |
| redirect\_url        | Browser to browser, Securepay platform will post to the endpoint browser.                                                                                                                                                                                                                           | Optional   |                                                                                                 |
| partner\_uid         | Partner UID value                                                                                                                                                                                                                                                                                   | optional   | c52853e0-24d6 .....                                                                             |
| currency             | SecurePay platform will convert the transaction amount into Malaysian Ringgit (RM/MYR). You need to pass the original currency value e.g: transaction\_amount is 2 and currency is USD. So the conversion will be generated at the current rate e.g: 9.22 MYR. At this momment we only support USD. | optional   | USD                                                                                             |
| cancel\_url          | SecurePay page for bank selection. If set the cancel URL. Button cancel will appear.                                                                                                                                                                                                                | optional   | <p>e.g: </p><p><https://yourdom.com/securepay>\_<em>cancel?order\_</em>number=123123</p><p></p> |
| timeout\_url         | SecurePay page for bank selection. if set the timeout URL. The page will timeout within 3 minutes                                                                                                                                                                                                   | optional   | <p>e.g: </p><p><https://yourdom.com/securepay_timeout><em>?order\_</em>number=123123</p>        |

### Set buyer\_name,buyer\_email,buyer\_phone,callback\_url and redirect\_url

**Request**

`curl -X POST https://sandbox.securepay.my/api/apis/payments -u 2aaa1633-e63f-4371-9b85-91d936aa56a1:ZyUfF8EmyabcMWPcaocX -d 'transaction_amount=200&order_number=231213&cancel_url=https://test.com&buyer_name=Amir Haris&buyer_email=amir@test.com&buyer_phone=01239997978&callback_url=https://test.com/callback&redirect_url=https://test.com/redirect'`

**Result**

{"payment\_url":"<https://sandbox.securepay.my/api/apis/RLIXQ1664333462/payment\\_session","data":{"buyer\\_name":"Amir> Haris","buyer\_email":"<amir@test.com>","buyer\_phone":"01239997978","transaction\_amount":"200.00","order\_number":"231213","product\_description":"Payment for order no. 231213","slug":"RLIXQ1664333462","callback\_url":"<https://test.com/callback","redirect\\_url":"https://test.com/redirect","cancel\\_url":"https://test.com","timeout\\_url":null,"currency":"MYR","currency\\_amount":"200.00","partner\\_uid":null,"other\\_params":null,"created\\_at":"2022-09-28T10:51:02.267+08:00","updated\\_at":"2022-09-28T10:51:02.267+08:00"}>

**Generated Payment Form** (<https://sandbox.securepay.my/api/apis/RLIXQ1664333462/payment\\_session>)

<figure><img src="/files/6xIUUXoqgNSz7HG8q3OB" alt=""><figcaption></figcaption></figure>

### Set currency and product\_description

**Request**

`curl -X POST https://sandbox.securepay.my/api/apis/payments -u 2aaa1633-e63f-4371-9b85-91d936aa56a1:ZyUfF8EmyabcMWPcaocX -d 'transaction_amount=200&order_number=231214&cancel_url=https://test.com&buyer_name=Amir Haris&buyer_email=amir@test.com&buyer_phone=01239997978&callback_url=https://test.com/callback&redirect_url=https://test.com/redirect&currency=USD&product_description=Electronic Picture Frame with order number 231214'`

**Result**

{"payment\_url":"<https://sandbox.securepay.my/api/apis/MKJUP1664333854/payment\\_session","data":{"buyer\\_name":"Amir> Haris","buyer\_email":"<amir@test.com>","buyer\_phone":"01239997978","transaction\_amount":"922.15","order\_number":"231214","product\_description":"Electronic Picture Frame with order number 231214","slug":"MKJUP1664333854","callback\_url":"<https://test.com/callback","redirect\\_url":"https://test.com/redirect","cancel\\_url":"https://test.com","timeout\\_url":null,"currency":"USD","currency\\_amount":"200.00","partner\\_uid":null,"other\\_params":null,"created\\_at":"2022-09-28T10:57:34.874+08:00","updated\\_at":"2022-09-28T10:57:34.874+08:00"}>

**Generated Payment Form** `(`<https://sandbox.securepay.my/api/apis/MKJUP1664333854/payment\\_session>)

<figure><img src="/files/duFazmUJDjqvc3bXfczW" alt=""><figcaption></figcaption></figure>


# Callback and Redirect URL

## Redirect URL (redirect\_url)

Merchant/partner can set redirect\_url during sending payment POST parameters. Redirect URL is browser to browser communication. After the bank transaction from the browser. The user will be redirected to this URL, merchant can set their own page. Information will be posted (POST method) to the URL. By default user will be redirected to SecurePay status page if the redirect URL is nil.

## Callback URL (callback\_url)

Merchant/partner can set callback\_url during sending payment POST parameters. Callback URL is server to server communication. SecurePay server sends the transaction status to the merchant callback server (based on callback URL). It's very important, if error occur on the redirect URL.

## Parameter from redirect and callback URL

This parameters will be sent to the URL by using POST method.

| Parameter                     | Description                                                                                                                                                            |
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| source                        | FPX or Credit Card                                                                                                                                                     |
| payment\_status               | True or False                                                                                                                                                          |
| currency                      | RM or other currency                                                                                                                                                   |
| transaction\_amount           | Transaction amount                                                                                                                                                     |
| transaction\_amount\_received | Amount received, if payment\_status false set to 0.00                                                                                                                  |
| order\_number                 | Order number send previously by merchant partner                                                                                                                       |
| merchant\_reference\_number   | This number is generated by SecurePay Platform                                                                                                                         |
| exchange\_number              | This number is generated by SecurePay Platform                                                                                                                         |
| buyer\_name                   | Buyer name                                                                                                                                                             |
| buyer\_phone                  | Buyer phone                                                                                                                                                            |
| buyer\_email                  | Buyer email                                                                                                                                                            |
| payment\_id                   | For reference                                                                                                                                                          |
| client\_ip                    | Client IP address                                                                                                                                                      |
| status\_url                   | SecurePay status URL                                                                                                                                                   |
| retry\_url                    | Any failed payment, can make retry using this links                                                                                                                    |
| receipt\_url                  | SecurePay PDF receipt URL                                                                                                                                              |
| checksum                      | Checksum generated by SecurePay for verification by merchant/partner                                                                                                   |
| transaction\_fee              | Transaction fee amount paid, merchant - deduct from amount, customer - customer will for the fee, credit - deduct from credit account.                                 |
| payment\_mode                 | merchant - deduct from amount, customer - customer will for the fee, credit - deduct from credit account.                                                              |
| payment\_method               | fpx online banking or fpx credit card                                                                                                                                  |
| fpx\_model                    | B2C - consumer or B2B1 - business                                                                                                                                      |
| fpx\_debit\_auth\_code        | 00 - success, 99 - pending approval, other codes - unsuccessful  .. If perform B2B1, there will be code 99 , after approval the server will send callback with code 00 |
| params                        | Resend params from API                                                                                                                                                 |

{% hint style="info" %}
Checksum is use to verify message that are received by SecurePay Platform for redirect and callback. The verification will be done on the merchant/partner side. (the string also need to include uid).
{% endhint %}

## Guide to generate checksum

Compulsory to use function that automatically sort the key and later replace with the value. Params will keep updating time to time.

Example&#x20;

{% tabs %}
{% tab title="PHP" %}

```
<?php
//Compulsory to use function that automatically sort the key and later replace with the value. Params will keep updating time to time.

private $checksum_token;

public function verify(Request $request)
    {

        $data = $request->all();
        ksort($data);

        $checksum = $data['checksum'];
        unset($data['checksum']);

        $string = implode('|', $data);

        $sign = hash_hmac('sha256', $string, $this->checksum_token);

        return ($sign == $checksum);
    }
?>
```

{% endtab %}

{% tab title="Rails or Ruby" %}

```
#Compulsory to use function that automatically sort the key and later replace with the value. Params will keep updating time to time.
#Token: df8aa0d55308ee762d2a5ce675cb9cfb4f85a59e41723573010e9c3f99f5457b
#Data: {:source=>"FPX", :fpx_name=>"N@ME()/ .-&BUYER", :fpx_bank=>"SBI BANK A", :fpx_transaction_id=>"2106141733330972", :fpx_status=>true, :fpx_status_message=>"Transaction Approved", :fpx_transaction_time=>"20210614173333", :fpx_model=>"B2C", :fpx_debit_auth_code=>"00", :payment_status=>true, :payment_method=>"fpx_online_banking", :payment_mode=>"customer", :transaction_fee=>"1.50", :currency=>"MYR", :amount=>"25.64", :order_number=>"20210614173332470", :merchant_reference_number=>nil, :exchange_number=>"MHQWK1623663213", :buyer_name=>"MOHD KHAIRI MOHD ADNAN", :buyer_phone=>"+600139803112", :buyer_email=>"khairi@localhost.my", :payment_stage=>"payment_successful", :merchant_name=>"Muslimah Next Store", :merchant_co_number=>"x111222122y", :payment_id=>5747, :client_ip=>"60.53.196.69", :uid=>"c111e3bc3c9c22d572dc", :status_url=>"https://sandbox.securepay.my/api/v1/status/MHQWK1623663213?uid=c111e3bc3c9c22d572dc", :retry_url=>nil, :receipt_url=>"https://sandbox.securepay.my/api/v1/receipt/MHQWK1623663213.pdf?uid=c111e3bc3c9c22d572dc", :params=>nil, :created_at=>Mon, 14 Jun 2021 17:33:48 +08 +08:00, :created_at_unixtime=>"1623663228", :token=>"6mtetdxEvzj6KJ9htyTy"}

def CheckSum.generate(token = "no_token", **data)
	  
	  data_sort_asc = data.sort_by {|k, v| k}

	  data_string = data_sort_asc.map {|k,v| v}.join("|")
	  
    generate_checksum = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), token, data_string)
      
    return generate_checksum
    
end

#Step 1 Sort key: amount|buyer_email|buyer_name|buyer_phone|client_ip|created_at|created_at_unixtime|currency|exchange_number|fpx_bank|fpx_debit_auth_code|fpx_model|fpx_name|fpx_status|fpx_status_message|fpx_transaction_id|fpx_transaction_time|merchant_co_number|merchant_name|merchant_reference_number|order_number|params|payment_id|payment_method|payment_mode|payment_stage|payment_status|receipt_url|retry_url|source|status_url|token|transaction_fee|uid
#Step 2 replace with value: 25.64|khairi@localhost.my|MOHD KHAIRI MOHD ADNAN|+600139803112|60.53.196.69|2021-06-14 17:33:48 +0800|1623663228|MYR|MHQWK1623663213|SBI BANK A|00|B2C|N@ME()/ .-&BUYER|true|Transaction Approved|2106141733330972|20210614173333|x111222122y|Muslimah Next Store||20210614173332470||5747|fpx_online_banking|customer|payment_successful|true|https://sandbox.securepay.my/api/v1/receipt/MHQWK1623663213.pdf?uid=c111e3bc3c9c22d572dc||FPX|https://sandbox.securepay.my/api/v1/status/MHQWK1623663213?uid=c111e3bc3c9c22d572dc|6mtetdxEvzj6KJ9htyTy|1.50|c111e3bc3c9c22d572dc

#Generated Checksum: 41712f0c155d1799c08e13add760de00b6a39e5a340360569253c360c2a40bbf
```

{% endtab %}
{% endtabs %}


# Transactions


# Status

## Endpoint URL

### Search using order number (generated by merchant)

| Environment | URL                                                                   | Method |
| ----------- | --------------------------------------------------------------------- | ------ |
| Sandbox     | <https://sandbox.securepay.my/api/v1/payments/status/:order\\_number> | GET    |
| Production  | <https://securepay.my/api/v1/payments/status/:order\\_number>         | GET    |

### Search using merchant number (generated by SecurePay)

| Environment | URL                                                                                                    |
| ----------- | ------------------------------------------------------------------------------------------------------ |
| Sandbox     | <https://sandbox.securepay.my/api/v1/payments/status/merchant\\_reference\\_number/:merchantrefnumber> |
| Production  | <https://securepay.my/api/v1/payments/status/merchant\\_reference\\_number/:merchantrefnumber>         |

{% hint style="info" %}
:order\_number is a unique order number generated by merchant end for reference.&#x20;
{% endhint %}

## Credentials

|                                 |                                      |
| ------------------------------- | ------------------------------------ |
| uid (Merchant API UID)          | 2aaa1633-e63f-4371-9b85-91d936aa56a1 |
| token (Merchant API Auth Token) | ZyUfF8EmyabcMWPcaocX                 |

## Example using curl

```bash
curl -u 2aaa1633-e63f-4371-9b85-91d936aa56a1:ZyUfF8EmyabcMWPcaocX https://sandbox.securepay.my/api/v1/payments/status/20200927045002577 | json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   786    0   786    0     0  16040      0 --:--:-- --:--:-- --:--:-- 16040
{
   "buyer_name" : "ADAM HARIS AHMAD",
   "buyer_phone" : "+60123122999",
   "exchange_number" : "MXKJI1601182203",
   "receipt_url" : "https://sandbox.securepay.my/api/v1/receipt/MXKJI1601182203.pdf?uid=e549ab7f07af9e52673e",
   "status_url" : "https://sandbox.securepay.my/api/v1/status/MXKJI1601182203?uid=e549ab7f07af9e52673e",
   "merchant_reference_number" : "MXKJI1601182203",
   "client_ip" : "14.192.210.186",
   "payment_status" : true,
   "transaction_amount" : "50.00",
   "order_number" : "20200927045002577",
   "currency" : "MYR",
   "buyer_email" : "amir@localhost.my",
   "payment_id" : 2159,
   "retry_url" : null,
   "interface_name": "Default",
   "interface_uid": "8db044bd-b450-4126-a0cd-101c0ba7b3ee",
   "source" : "FPX",
   "transaction_amount_received" : "50.00",
   "created_at": "2020-09-29T19:15:42.419+08:00",
   "created_at_unixtime": "1601378142"
}
```

## Response values

| Parameter                     | Description                                                |
| ----------------------------- | ---------------------------------------------------------- |
| source                        | FPX, Credit Card or other                                  |
| payment\_status               | true - success payment and false - failed payment          |
| currency                      | RM - Ringgit Malaysia (other currencies are not supported) |
| transaction\_amount           | Amount in RM for this transaction.                         |
| transaction\_amount\_received | Amount received, if payment\_status false set to 0.00      |
| order\_number                 | Order Number sent previously by merchant.                  |
| merchant\_reference\_number   | This number is generated by securepay platform             |
| exchange\_number              | This number is generated by securepay platform             |
| buyer\_name                   | Buyer name                                                 |
| buyer\_phone                  | Buyer phone                                                |
| buyer\_email                  | Buyer email                                                |
| interface\_name               | API name                                                   |
| interface\_uid                | API UID                                                    |
| payment\_id                   | For reference                                              |
| client\_ip                    | Client IP address                                          |
| status\_url                   | SecurePay Status URL                                       |
| retry\_url                    | Any failed payment, can make retry using this links        |
| receipt\_url                  | SecurePay PDF receipt URL                                  |
| created\_at                   | Created date and time ISO8601 format                       |
| created\_at\_unixtime         | Created date and time in unix time epoch format            |


# List

Merchant can fetch their transactions.

## Endpoint URL

| Environment | URL                                                     | Method |
| ----------- | ------------------------------------------------------- | ------ |
| Sandbox     | <https://sandbox.securepay.my/api/v1/transactions/list> | GET    |
| Production  | <https://securepay.my/api/v1/transactions/list>         | GET    |

## Credentials

|                                 |                                      |
| ------------------------------- | ------------------------------------ |
| uid (Merchant API UID)          | 2aaa1633-e63f-4371-9b85-91d936aa56a1 |
| token (Merchant API Auth Token) | ZyUfF8EmyabcMWPcaocX                 |

## Parameters

| Parameter       | Description                                                                       |
| --------------- | --------------------------------------------------------------------------------- |
| per\_page       | How many data to display, default is 10 data and maximum 100 per page             |
| page            | Jump into a page. e.g: the data have 5 pages, to visit 3rd page just set page = 3 |
| payment\_status | Success payment is set to true and false for unsuccessful.                        |
| start\_date     | Search data by date range e.g start\_date: 2020-09-10                             |
| end\_date       | Search data by date range e.g end\_date: 2020-09-15                               |

{% hint style="info" %}
Default parameters list will be applied (refer Default section), If no parameters are supply during API request.
{% endhint %}

{% hint style="warning" %}
Both start\_date and end\_date need to be supplied for date range search. E.g For daily transaction on 20/09/2020 need to set start\_date=2020-09-20 and end\_date=2020-09-20&#x20;
{% endhint %}

| <https://sandbox.securepay.my/api/v1/transactions/list?start\\_date=2020-09-20\\&end\\_date=2020-09-20> |
| ------------------------------------------------------------------------------------------------------- |

## Default

Per page: 10\
Maximum per page: 100 (Please use pagination if data more than 100)\
Payment status: Success (True)\
Data search limit: 3 months (90 days)

## Paginate <a href="#paginate" id="paginate"></a>

‌

Fetch 5 payments per page‌

<https://sandbox.securepay.my/api/v1/payments/list?per\\_page=5>

```
curl -u 2aaa1633-e63f-4371-9b85-91d936aa56a1:ZyUfF8EmyabcMWPcaocX https://sandbox.securepay.my/api/v1/transactions/list?per_page=1 | json_pp 
```

```
‌{
   "next_page" : 2,
   "current_page" : 1,
   "per_page" : 1,
   "total_page" : 375,
   "prev_page" : null,
   "total_entries" : 375,
   "transactions" : [
      {
         "merchant_reference_number" : "IJNQS1629161503",
         "fpx_debit_auth_code" : "00",
         "interface_uid" : "4a73a364-6548-4e17-9130-c6e9bffa3081",
         "payment_stage" : "payment_successful",
         "buyer_name" : "abu",
         "fpx_model" : "B2C",
         "currency" : "MYR",
         "merchant_name" : "SP SDN BHD",
         "client_ip" : "103.145.216.156",
         "payment_id" : 8172,
         "order_number" : "7A2C840800",
         "created_at" : "2021-08-17T08:51:51.156+08:00",
         "source" : "FPX",
         "retry_url" : null,
         "fpx_transaction_time" : "20210817085144",
         "payment_method" : "fpx_online_banking",
         "payment_mode" : "merchant",
         "fpx_bank" : "SBI BANK A",
         "merchant_co_number" : "1273013-P",
         "receipt_url" : "https://sandbox.securepay.my/api/v1/receipt/IJNQS1629161503.pdf?uid=67a90303bfa6d891070c",
         "transaction_amount" : "20.00",
         "fpx_name" : "N@m3()/PYN .-&B'UYER",
         "fpx_transaction_id" : "2108170851440009",
         "fpx_status" : true,
         "status_url" : "https://sandbox.securepay.my/api/v1/status/IJNQS1629161503?uid=67a90303bfa6d891070c",
         "uid" : "67a90303bfa6d891070c",
         "created_at_unixtime" : "1629161512",
         "payment_status" : true,
         "transaction_fee" : "1.20",
         "fpx_status_message" : "Transaction Approved",
         "transaction_amount_received" : "20.00",
         "interface_name" : "Default",
         "buyer_phone" : "",
         "buyer_email" : "nawawijamili@gmail.com"
      }
   ]
}

```

**Getting second page‌**

<https://sandbox.securepay.my/api/v1/transactions/list?per\\_page=5\\&page=2>

**Example fetch 100 payments**&#x20;

<https://sandbox.securepay.my/api/v1/transactions/list?per\\_page=100>

**Example fetch 100 payments on page 3**

<https://sandbox.securepay.my/api/v1/transactions/list?per\\_page=100\\&page=3‌>

## Payment status <a href="#payment-status" id="payment-status"></a>

‌

There are true and false for payment status.‌

True status - Payment successfully received‌

False Status - Payment not successfully go through‌

To request the list by payment status e.g:&#x20;

1\. request success payment status (default) `https://sandbox.securepay.my/api/v1/transactions/list?payment_status`‌

`https://sandbox.securepay.my/api/v1/transactions/list?payment_status=true`‌

2\. request failed payment status `https://sandbox.securepay.my/api/v1/transactions/list?payment_status=false`‌

3\. request success and failed status`https://sandbox.securepay.my/api/v1/transactions/list?payment_status=all`‌

4\. request success payment status with 10 data on page 2 `https://sandbox.securepay.my/api/v1/transactions/list?payment_status=true&per_page=10&page=2`

By default, if no payment\_status is set the API will return success (true) status.‌

## Data created date and time <a href="#data-created-date-and-time" id="data-created-date-and-time"></a>

‌

Each data will have two types of format:&#x20;

1\. created\_at e.g: 2020-09-27T17:19:43.593+08:00 2. created\_at\_unixtime e.g: 1601198383​![](https://gblobscdn.gitbook.com/assets%2F-MHFsN346MN-4Eibh12Q%2F-MIADYzriRPM9l4dcsR1%2F-MIDvPjStEFupUKv8-Uw%2FScreenshot%202020-09-27%20at%205.38.31%20PM.png?alt=media\&token=8bf20b22-031d-4b38-a916-e920da2f3d3e)‌

## Get daily transaction list <a href="#get-daily-transaction-list" id="get-daily-transaction-list"></a>

‌

Below example set start\_date = 2020-09-27 and end\_date = 2020-09-27

```
https://sandbox.securepay.my/api/v1/transactions/list?payment_status=all&per_page=50&end_date=2020-09-28&start_date=2020-09-27​
```

‌

## Search by date range <a href="#search-by-date-range" id="search-by-date-range"></a>

‌

Below example set start\_date = 2020-09-15 and end\_date = 2020-09-27

```
https://sandbox.securepay.my/api/v1/transactions/list?payment_status=false&per_page=5&end_date=2020-09-28&start_date=2020-09-15​
```

‌

## Example using curl <a href="#example-using-curl" id="example-using-curl"></a>

Example 2 with header

```
curl -u 2aaa1633-e63f-4371-9b85-91d936aa56a1:ZyUfF8EmyabcMWPcaocX https://sandbox.securepay.my/api/v1/transactions/list?per_page=2 | json_pp 
```

## Response values <a href="#response-values" id="response-values"></a>

| Parameter                     | Description                                                |
| ----------------------------- | ---------------------------------------------------------- |
| source                        | FPX, Credit Card or other                                  |
| payment\_status               | true - success payment and false - failed payment          |
| currency                      | RM - Ringgit Malaysia (other currencies are not supported) |
| transaction\_amount           | Amount in RM for this transaction.                         |
| transaction\_amount\_received | Amount received, if payment\_status false set to 0.00      |
| order\_number                 | Order Number sent previously by merchant.                  |
| merchant\_reference\_number   | This number is generated by securepay platform             |
| exchange\_number              | This number is generated by securepay platform             |
| buyer\_name                   | Buyer name                                                 |
| buyer\_phone                  | Buyer phone                                                |
| buyer\_email                  | Buyer email                                                |
| payment\_id                   | For reference                                              |
| transaction\_fee              | Transaction fee                                            |
| fpx\_model                    | B2C or B2B1                                                |
| payment\_mode                 | merchant, buyer or merchant\_credit                        |
| payment\_method               | fpx\_online banking or credit card                         |
| client\_ip                    | Client IP address                                          |
| status\_url                   | SecurePay Status URL                                       |
| retry\_url                    | Any failed payment, can make retry using this links        |
| receipt\_url                  | SecurePay PDF receipt URL                                  |
| created\_at                   | Created date and time ISO8601 format                       |
| created\_at\_unixtime         | Created date and time in unix time epoch format            |


# Search

Merchant can search any transactions

## Endpoint URL

| Environment | URL                                                       | Method |
| ----------- | --------------------------------------------------------- | ------ |
| Sandbox     | <https://sandbox.securepay.my/api/v1/transactions/search> | GET    |
| Production  | <https://securepay.my/api/v1/transactions/search>         | GET    |

## Credentials

|                                 |                                      |
| ------------------------------- | ------------------------------------ |
| uid (Merchant API UID)          | 2aaa1633-e63f-4371-9b85-91d936aa56a1 |
| token (Merchant API Auth Token) | ZyUfF8EmyabcMWPcaocX                 |

{% hint style="info" %}
SecurePay supports multiple credentials. Merchant can use any credentials set in order to request search commands using API.&#x20;
{% endhint %}

## Parameters

Merchant can search with the below elements:\
\- FPX Reference Number\
\- Order Number (seller)\
\- Exchange Number (Generated by SecurePay)

| Parameter         | Description                                                        |
| ----------------- | ------------------------------------------------------------------ |
| search\_reference | <p>fpx\_ref\_number</p><p>order\_number</p><p>exchange\_number</p> |
| reference\_number | Reference number from search elements (search\_reference)          |

## Example

```
curl -u 4a73a364-6548-4e17-9130-c6e9bffa3081:GFVnVXHzGEyfzzPk23er "https://sandbox.securepay.my/api/v1/transactions/search?search_reference=order_number&reference_number=1208" | json_pp

[
   {
      "buyer_email" : "me@ppp.com",
      "buyer_name" : "Michael Bay",
      "buyer_phone" : "01261112121",
      "client_ip" : "103.145.216.156",
      "created_at" : "2021-08-10T16:11:28.524+08:00",
      "created_at_unixtime" : "1628583088",
      "currency" : "MYR",
      "fpx_bank" : "CIMB BANK",
      "fpx_debit_auth_code" : "76",
      "fpx_model" : "B2C",
      "fpx_name" : "",
      "fpx_status" : false,
      "fpx_status_message" : "Transaction Not Found",
      "fpx_transaction_id" : "2108101554520476",
      "fpx_transaction_time" : "20210810155452",
      "interface_name" : "Default",
      "interface_uid" : "4a73a364-6548-4e17-9130-c6e9bffa3081",
      "merchant_co_number" : "1273013-P",
      "merchant_name" : "SP SDN BHD",
      "merchant_reference_number" : "OBDEM1628582057",
      "order_number" : "1208",
      "payment_id" : 7893,
      "payment_method" : null,
      "payment_mode" : "merchant",
      "payment_stage" : "payment_unsuccessful",
      "payment_status" : false,
      "receipt_url" : null,
      "retry_url" : "https://sandbox.securepay.my/api/v1/retry/OBDEM1628582057?uid=ef12813a45cb7fb9852e",
      "source" : "FPX",
      "status_url" : "https://sandbox.securepay.my/api/v1/status/OBDEM1628582057?uid=ef12813a45cb7fb9852e",
      "transaction_amount" : "55.89",
      "transaction_amount_received" : "0.00",
      "transaction_fee" : "0.00",
      "uid" : "ef12813a45cb7fb9852e"
   }
]

```


# List (deprecated and no longer available)

Merchant can fetch their transactions. This endpoint is no longer available, please refer to new one.

## Endpoint URL

| Environment | URL                                                 | Method |
| ----------- | --------------------------------------------------- | ------ |
| Sandbox     | <https://sandbox.securepay.my/api/v1/payments/list> | GET    |
| Production  | <https://securepay.my/api/v1/payments/list>         | GET    |

## Credentials

|                                 |                                      |
| ------------------------------- | ------------------------------------ |
| uid (Merchant API UID)          | 2aaa1633-e63f-4371-9b85-91d936aa56a1 |
| token (Merchant API Auth Token) | ZyUfF8EmyabcMWPcaocX                 |

## Parameters

| Parameter       | Description                                                                       |
| --------------- | --------------------------------------------------------------------------------- |
| per\_page       | How many data to display, default is 10 data and maximum 100 per page             |
| page            | Jump into a page. e.g: the data have 5 pages, to visit 3rd page just set page = 3 |
| payment\_status | Success payment is set to true and false for unsuccessful.                        |
| start\_date     | Search data by date range e.g start\_date: 2020-09-10                             |
| end\_date       | Search data by date range e.g end\_date: 2020-09-15                               |

{% hint style="info" %}
Default parameters list will be applied (refer Default section), If no parameters are supply during API request.
{% endhint %}

{% hint style="warning" %}
Both start\_date and end\_date need to be supplied for date range search. E.g For daily transaction on 20/09/2020 need to set start\_date=2020-09-20 and end\_date=2020-09-20&#x20;
{% endhint %}

| <https://sandbox.securepay.my/api/v1/payments/list?start\\_date=2020-09-20\\&end\\_date=2020-09-20> |
| --------------------------------------------------------------------------------------------------- |

## Default

Per page: 10\
Maximum per page: 100 (Please use pagination if data more than 100)\
Payment status: Success (True)\
Data search limit: 3 months (90 days)

## Paginate

Fetch 5 payments per page&#x20;

<https://sandbox.securepay.my/api/v1/payments/list?per\\_page=5>

{% hint style="info" %}
and the response will be paginated and also will include pagination headers
{% endhint %}

Get pagination info from header

![Pagination headers](/files/-MI7E9ppLixeTB_JKzkk)

{% tabs %}
{% tab title="CURL" %}

```bash
curl -i -H "Application/json" -u 2aaa1633-e63f-4371-9b85-91d936aa56a1:ZyUfF8EmyabcMWPcaocX https://sandbox.securepay.my/api/v1/payments/list?per_page=5

```

{% endtab %}

{% tab title="PHP" %}

```php
```

{% endtab %}

{% tab title="RUBY" %}

```ruby
```

{% endtab %}
{% endtabs %}

```
X-Total: 6
X-Total-Pages: 2
X-Page: 1
X-Per-Page: 5
X-Next-Page: 2
X-Prev-Page: 
X-Offset: 
```

Getting second page

<https://sandbox.securepay.my/api/v1/payments/list?per\\_page=5\\&page=2>

```
X-Total: 6
X-Total-Pages: 2
X-Page: 2
X-Per-Page: 5
X-Next-Page: 
X-Prev-Page: 1
X-Offset: 
```

{% hint style="info" %}
Example fetch 100 payments data
{% endhint %}

<https://sandbox.securepay.my/api/v1/payments/list?per\\_page=100>

```
X-Total: 380
X-Total-Pages: 4
X-Page: 1
X-Per-Page: 100
X-Next-Page: 2
X-Prev-Page: 
X-Offset: 
```

<https://sandbox.securepay.my/api/v1/payments/list?per\\_page=100\\&page=3>

```
X-Total: 380
X-Total-Pages: 4
X-Page: 3
X-Per-Page: 100
X-Next-Page: 4 
X-Prev-Page: 2
X-Offset: 
```

## Payment status

There are true and false for payment status.

True status - Payment successfully received

False Status - Payment not successfully go through

To request the list by payment status e.g:\
1\. request success payment status (default)\
`https://sandbox.securepay.my/api/v1/payments/list?payment_status`

`https://sandbox.securepay.my/api/v1/payments/list?payment_status=true`

2\. request failed payment status\
`https://sandbox.securepay.my/api/v1/payments/list?payment_status=false`

3\. request success and failed status`https://sandbox.securepay.my/api/v1/payments/list?payment_status=all`

4\. request success payment status with 10 data on page 2\
`https://sandbox.securepay.my/api/v1/payments/list?payment_status=true&per_page=10&page=2`

{% hint style="info" %}
By default if no payment\_status is set the API will return success (true) status.
{% endhint %}

## Data created date and time

Each data will have two types of format:\
1\. created\_at e.g: 2020-09-27T17:19:43.593+08:00\
2\. created\_at\_unixtime e.g: 1601198383

<div align="left"><img src="/files/-MIDvPjStEFupUKv8-Uw" alt=""></div>

## Get daily transaction list

Below example set start\_date = 2020-09-27 and end\_date = 2020-09-27

```
https://sandbox.securepay.my/api/v1/payments/list?payment_status=all&per_page=50&end_date=2020-09-28&start_date=2020-09-27

```

## Search by date range

Below example set start\_date = 2020-09-15 and end\_date = 2020-09-27

```
https://sandbox.securepay.my/api/v1/payments/list?payment_status=false&per_page=5&end_date=2020-09-28&start_date=2020-09-15

```

## Example using curl

{% tabs %}
{% tab title="Example 1 print pretty JSON" %}

```bash
curl -u 2aaa1633-e63f-4371-9b85-91d936aa56a1:ZyUfF8EmyabcMWPcaocX https://sandbox.securepay.my/api/v1/payments/list?per_page=2 | json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1367    0  1367    0     0  14698      0 --:--:-- --:--:-- --:--:-- 14698
[
   {
      "payment_status" : true,
      "exchange_number" : "TCKVR1601378132",
      "client_ip" : "175.139.210.207",
      "payment_id" : 2171,
      "retry_url" : null,
      "status_url" : "https://sandbox.securepay.my/api/v1/status/TCKVR1601378130?uid=266c1e922692a8dc1187",
      "source" : "FPX",
      "created_at_unixtime" : "1601378142",
      "transaction_amount" : "50.00",
      "created_at" : "2020-09-29T19:15:42.419+08:00",
      "transaction_amount_received" : "50.00",
      "buyer_name" : "ADAM HARIS AHMAD",
      "merchant_reference_number" : "TCKVR1601378130",
      "receipt_url" : "https://sandbox.securepay.my/api/v1/receipt/TCKVR1601378130.pdf?uid=266c1e922692a8dc1187",
      "order_number" : "20200929111530266",
      "currency" : "MYR",
      "buyer_phone" : "+60123121977",
      "buyer_email" : "amir@localhost.my"
   },
   {
      "retry_url" : null,
      "exchange_number" : "KWATI1601198351",
      "payment_status" : true,
      "payment_id" : 2161,
      "client_ip" : "14.192.214.33",
      "created_at_unixtime" : "1601198383",
      "source" : "FPX",
      "transaction_amount" : "50.00",
      "status_url" : "https://sandbox.securepay.my/api/v1/status/KWATI1601198371?uid=201b7fa16595498091cb",
      "merchant_reference_number" : "KWATI1601198351",
      "buyer_name" : "AMIR DAUD AHMAD",
      "receipt_url" : "https://sandbox.securepay.my/api/v1/receipt/KWATI1601198371.pdf?uid=201b7fa16595498091cb",
      "transaction_amount_received" : "50.00",
      "created_at" : "2020-09-27T17:19:43.593+08:00",
      "buyer_phone" : "+60123121977",
      "currency" : "MYR",
      "buyer_email" : "amir@localhost.my",
      "order_number" : "20200927091930866"
   }
]

```

{% endtab %}

{% tab title="Example 2 with header" %}

```
curl -i -H "Application/json" -u 2aaa1633-e63f-4371-9b85-91d936aa56a1:ZyUfF8EmyabcMWPcaocX https://sandbox.securepay.my/api/v1/payments/list?per_page=2 
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 29 Sep 2020 11:36:24 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
X-Total: 28
X-Total-Pages: 14
X-Per-Page: 2
X-Page: 1
X-Next-Page: 2
X-Prev-Page: 
X-Offset: 
ETag: W/"a2d73a83d773e66cc023fe31be19d70f"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 276151ec-7fb4-4e62-b7da-6b44ff00f6ea
X-Runtime: 0.028449
Vary: Origin
X-XSS-Protection: 1; mode=block
Expect-CT: max-age=0
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

[{"source":"FPX","payment_status":true,"currency":"MYR","transaction_amount":"50.00","transaction_amount_received":"50.00","order_number":"20200929111530266","merchant_reference_number":"TCKVR1601378132","exchange_number":"TCKVR1601378132","buyer_name":"ADAM HARIS AHMAD","buyer_phone":"+60123121977","buyer_email":"amir@localhost.my","payment_id":2171,"client_ip":"175.139.210.207","status_url":"https://sandbox.securepay.my/api/v1/status/TCKVR1601378130?uid=266c1e922692a8dc1187","retry_url":null,"receipt_url":"https://sandbox.securepay.my/api/v1/receipt/TCKVR1601378130.pdf?uid=266c1e922692a8dc1187","created_at":"2020-09-29T19:15:42.419+08:00","created_at_unixtime":"1601378142"},{"source":"FPX","payment_status":true,"currency":"MYR","transaction_amount":"50.00","transaction_amount_received":"50.00","order_number":"20200927091930816","merchant_reference_number":"KWATI1601198371","exchange_number":"KWATI1601198371","buyer_name":"AMIR HARIS AHMAD","buyer_phone":"+60123121979","buyer_email":"amir@localhost.my","payment_id":2161,"client_ip":"14.192.214.33","status_url":"https://sandbox.securepay.my/api/v1/status/KWATI1601198371?uid=201b7fa16595498091cb","retry_url":null,"receipt_url":"https://sandbox.securepay.my/api/v1/receipt/KWATI1601198371.pdf?uid=201b7fa16595498091cb","created_at":"2020-09-27T17:19:43.593+08:00","created_at_unixtime":"1601198383"}]a
```

{% endtab %}
{% endtabs %}

## Response values

| Parameter                     | Description                                                |
| ----------------------------- | ---------------------------------------------------------- |
| source                        | FPX, Credit Card or other                                  |
| payment\_status               | true - success payment and false - failed payment          |
| currency                      | RM - Ringgit Malaysia (other currencies are not supported) |
| transaction\_amount           | Amount in RM for this transaction.                         |
| transaction\_amount\_received | Amount received, if payment\_status false set to 0.00      |
| order\_number                 | Order Number sent previously by merchant.                  |
| merchant\_reference\_number   | This number is generated by securepay platform             |
| exchange\_number              | This number is generated by securepay platform             |
| buyer\_name                   | Buyer name                                                 |
| buyer\_phone                  | Buyer phone                                                |
| buyer\_email                  | Buyer email                                                |
| payment\_id                   | For reference                                              |
| client\_ip                    | Client IP address                                          |
| status\_url                   | SecurePay Status URL                                       |
| retry\_url                    | Any failed payment, can make retry using this links        |
| receipt\_url                  | SecurePay PDF receipt URL                                  |
| created\_at                   | Created date and time ISO8601 format                       |
| created\_at\_unixtime         | Created date and time in unix time epoch format            |


# Guides


# Create Account

Tutorial how to create account

{% embed url="<https://youtu.be/ny0LSeiAtEc>" %}
How to in Bahasa Malaysia
{% endembed %}


# Referral

Merchant can introduce SecurePay to other and we will reward you. E.g: We will give you SecurePay Tshirt and more perks to come.

{% embed url="<https://youtu.be/CRjTS7bIl8E>" %}


# Premium Domain

{% embed url="<https://youtu.be/YWSh9_hugfI>" %}


# Settlement

Ts. Amir Haris explains about settlement. At this moment the settlement period is T+1 (next business day).

{% embed url="<https://youtu.be/W9dVQGeeTsI>" %}
SecurePay Settlement
{% endembed %}


# FPX Credit Card

{% embed url="<https://youtu.be/FY2MAV0LY7A>" %}


# Payment Form


# Create a form to receive payment

{% embed url="<https://youtu.be/SeIzArkR9uA>" %}


# Create custom fields

{% embed url="<https://youtu.be/a_0yaVrghro>" %}


# Enable Quantity, Billing/Shipping fields

{% embed url="<https://youtu.be/6W_DXCUk36g>" %}


# Payment mode


# Enable amount selection


# API


# Settlement

{% embed url="<https://youtu.be/W9dVQGeeTsI>" %}


# Plugins


# WooCommerce

{% embed url="<https://youtu.be/oek-g5pIoBM>" %}


# Payment Service Agent (PSA)


# Change Logs

Start from 14 June 2021, changes will be documented

## 14 June 2021

* Enable support for B2B1
* Payment mode now support merchant, customer and merchant\_credit
* Payment API is now accept billing\_address, shipping\_address
* Extra parameters for callback and redirect e.g: transaction\_fee, fpx\_model, payment\_mode, fpx\_debit\_auth\_code
* Payment dropdown or grid bank view

## 25 July 2021

* Settlement statement can be downloaded from dashboard on settlement section.
* Please select bank is now appear on the banks selection list.
* Faster statistic loads on dashboard implementing sketch and stream algorithm.
* Load balance on premium domain infrastructure.&#x20;
* New architecture (backend) design on web and SSL services. Now everything are API ready.
* Statistic is now can be displayed as per API.
* Bank selection on the form page (previous the bank selection page is after form page)

<br>


