NAV
curl

1. Document Illustration


	
	

The documents provider is DusPay, we focus on providing our merchants a standard API integration rules. We have the right of final explanation on the document and have reserved right to update it any time.

  1. After using the document, you can achieve the following functions: 'Accept credit payment online', 'Query order information', 'Refund the order' and so on.
  2. The documents reader is merchants' administrator, maintainer and developer.
  3. Except defined, platform mentioned in this document means DusPay.

2. Preparation

Example of API code to user for Integration:

DUSPAY.COM MERCHANT:

	<!--Merchant Id: 521
	Secure API Key: MguwLM0iJU
	Product Key Id: 85-->

	<input type="hidden" name="member" value="521"/>
	<input type="hidden" name="bid" value="MguwLM0iJU"/>
	<input type="hidden" name="product" value="85"/>


	
  1. Read all the API document carefully.
  2. Obtain 3 very important parameters,they are "member" , "bid" , "product".
Parameter Description
member
int M
required
Merchant ID is your MID number. You can get MID in "Account Settings" page by follwing these steps Welcome → View/Edit Profile.
bid
str M
required
Secure API Key is a string value. You can find it by following Welcome → View/Edit Profile
product
int M
required
Product Key is very important parameter and you can find it easily followed by My Money → Products →Add A New Product.

3. Payment Gateway (Direct)

Example of Payment Gateway (Direct):

	
$gateway_url="https://portal.duspay.com/api.htm";
$curlPost=array();
//<!--Replace of 3 very important parameters * your product API code -->

$curlPost["member"]="521";         // Merchant ID  
$curlPost["bid"]="MguwLM0iJU";    // Secure API Key 
$curlPost["product"]="85";        // Merchant Product Key 
$curlPost["accountid"]="D2003";    // Merchant Account Id 

//<!--default (fixed) value * default -->

$curlPost["cardsend"]="curl";
$curlPost["action"]="product";
$curlPost["mode"]="live";

//<!--product price and product name * by cart total amount -->

$curlPost["price"]="999.00";
$curlPost["product_name"]="I phone-7";

//<!--billing details of .* customer -->

$curlPost["ccholder"]="Mith";
$curlPost["ccholder_lname"]="San";
$curlPost["email"]="mith.san@gmail.com";
$curlPost["bill_street_1"]="25A Alpha";
$curlPost["bill_street_2"]="tagore lane";
$curlPost["bill_city"]="Jurong";
$curlPost["bill_state"]="Singapore";
$curlPost["bill_country"]="Singapore";
$curlPost["bill_zip"]="787602";
$curlPost["bill_phone"]="+65 62200944";
$curlPost["id_order"]="20170131";
$curlPost["notify_url"]="https://yourdomain.com/notify.php";

//<!--card details of .* customer -->

$curlPost["ccno"]="4242424242424242";
$curlPost["ccvv"]="123";
$curlPost["month"]="01";
$curlPost["year"]="20";
$curlPost["notes"]="Remark for transaction";

$protocol = isset($_SERVER["HTTPS"])?'https://':'http://';
$referer=$protocol.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; 

$curl_cookie="";
$curl = curl_init(); 
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($curl, CURLOPT_URL, $gateway_url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($curl, CURLOPT_REFERER, $referer);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
curl_setopt($curl, CURLOPT_TIMEOUT, 300);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_COOKIE,$curl_cookie);
$response = curl_exec($curl);

After posting the data you will get below response:

{
    "transaction_id": "20171010122934",
    "status_nm": "1",
    "status": "Completed",
    "price": "999.00",
    "curr": "USD",
    "id_order": "20170131",
    "cardtype": "visa",
    "ccno": "XXXXXXXXXXXX4242",
    "reason": "success",
    "fullname": "Mith San",
    "email": "mith.san@gmail.com",
    "address": "25A Alpha,tagore lane ",
    "city": "Jurong",
    "state": "Singapore",
    "country": "Singapore",
    "phone": "+65 62200944",
    "product_name": "I phone-7",
    "amt": "999.00",
    "memail": "billing@duspay.com",
    "company": "duspay.com",
    "bussinessurl": "https://www.duspay.com",
    "contact_us_url": "https://www.duspay.com/contact-us",
    "customer_service_no": "912233445566",
    "tdate": "2017-10-11 10:30:09",
   
    "callbacks": "OK",
    "info": {
        "mode": "live",
        "accountid": "D2003",
        "ccholder": "Mith",
        "ccholder_lname": "San",
        "email": "mith.san@gmail.com"
        "etc...": .....
    }
}

Echo for your data of response:

function jsonvaluef($theArray,$keyName,$array2=''){
  $theArray1=str_replace(array('{"','"}'),array('','","'),$theArray);
  if((!empty($theArray1))&&(strpos($theArray,$keyName)!==false)){
	if(!empty($array2)){
		$theArray1=explode($array2, $theArray1); 
		$theArray1=$theArray1[1];
	}
	$keyName1=explode($keyName.'":"', $theArray1);
	if(!empty($keyName1[1])){
		$keyName2=explode('","', $keyName1[1]);
		return $keyName2[0];
	}
  }
}

echo jsonvaluef($response,"transaction_id");

echo jsonvaluef($response,"price");

echo jsonvaluef($response,"status");

echo jsonvaluef($response,"reason");

By post method or get method to use parameters are registered members [DusPay.com Merchant] to make sure the values won’t be changed.

Rules to generate an API code:

  1. Merchant Login -To login the dashboard, Merchant require username & password.
  2. To add or modify setting - After Login to welcome →settings → complete Merchant Profile → save changes.
  3. To Add New Products - Click on My Money → Products →Add A New Product
  4. Generate Code - After adding product details code will be generated automatically. This code is required when you proceed for Payment Integration.
Gateway URL https://portal.duspay.com/api.htm
Method POST
Function Accept credit card payment online from the customers
Remark 11 mandatory parameters, the others are all optional
Parameter Description
member
int M
required
Merchant ID,an integer and you will use it to login the merchant dashboard. You will find it in the "Account settings" page. You will find merchant login to Welcome → View/Edit Profile..
bid
str M
required
Secure API Key, a string for very important parameter and you will use it to login the merchant dashboard. You will find it in the "Account settings" page.
product
int M
required
Product Key Id,an integer for very important parameter and you will use to Click on My Money → Products →Add A New Product.
accountid
str M
required
accountid, a string in 5 digit for very important parameter value e.g.D2003.
cardsend
str D
required
cardsend, a string for default (fixed) value curl.
action
str D
required
action, a string for default (fixed) value product.
mode
str D
required
mode, a string for default (fixed) value live. (live or test)
price
dec(10,2) M
required
Order Amount, currency format in decimal(10,2)
product_name
str M
required
Product Name
ccholder
str C
required
Customer first name
ccholder_lname
str C
required
Customer last name
email
str C
required
Customer billing email
bill_street_1
str C
optional
Customer's shipping street
bill_street_2
str C
optional
Customer's shipping street 2
bill_city
str C
optional
Customer's shipping city
bill_state
str C
optional
Customer's shipping state
bill_country
str C
required
Customer's shipping country
bill_zip
str C
optional
Customer's shipping zip code
bill_phone
str C
required
Customer billing phone
id_order
str M
optional
Merchant’s order ID that will be returned back in a callback.
notify_url
str M
optional
Synchronous notification URL, you can find it in the response data.
success_url
str M
optional
Redirect url of success as per your domain
error_url
str M
optional
Redirect url of error as per your domain

4. Payment Gateway (Host)

Example of Payment Gateway (Host):

<form method="post" action="https://portal.duspay.com/processall.htm" name="duspayform">

	<!--Replace of 3 very important parameters * your product API code -->

	<input type="hidden" name="member" value="521"/>
	<input type="hidden" name="bid" value="MguwLM0iJU"/>
	<input type="hidden" name="product" value="85"/>

	<!--default (fixed) value * default -->

	<input type="hidden" name="cardsend" value="CHECKOUT"/>
	<input type="hidden" name="action" value="product"/>
	<input type="hidden" name="mode" value="live"/>

	<!--product price and product name * by cart total amount -->

	<input type="hidden" name="price" value="999.00"/>
	<input type="hidden" name="product_name" value="I phone-	7"/>
	
	<!--billing details of .* customer -->

	<input type="hidden" name="ccholder" value="Mith"/>
	<input type="hidden" name="ccholder_lname" value="San"/>
	<input type="hidden" name="email" value="mith.san@gmail.com"/>
	<input type="hidden" name="bill_street_1" value="25A Alpha"/>
	<input type="hidden" name="bill_street_2" value="tagore lane"/>
	<input type="hidden" name="bill_city" value="Jurong"/>
	<input type="hidden" name="bill_state" value="Singapore"/>
	<input type="hidden" name="bill_country" value="Singapore"/>
	<input type="hidden" name="bill_zip" value="787602"/>
	<input type="hidden" name="bill_phone" value="+65 62200944"/>
	<input type="hidden" name="id_order" value="20170131"/>
	<input type="hidden" name="notify_url" value="https://yourdomain.com/notify.php"/>
	<input type="hidden" name="success_url" value="https://yourdomain.com/success.php"/>
	<input type="hidden" name="error_url" value="https://yourdomain.com/error.php"/>
	
	<javascript>document.duspayform.submit();</javascript>

</form>

To pass the parameters, we accept both POST method or GET method.

Steps to generate an API code:

  1. Merchant Login -To login the dashboard, username & password is mandatory.
  2. To Add or Modify Setting - After Login, kindly follow these steps Welcome →View/Edit Profile → Save Changes.
  3. To Add New Products - Click on My Money → Products →Add A New Product.
  4. Generate Code - After adding product details, code will be generated automatically. This code is required when you proceed for payment integration.
Gateway URL https://portal.duspay.com/processall.htm
Method POST or GET
Function Accept Check or Credit card payment online from the customers
Remark 10 mandatory parameters, the others are all optional
Parameter Description
member
int M
required
Merchant ID is your MID number. You can get MID in "Account Settings" page by following these steps Welcome → View/Edit Profile.
bid
str M
required
Secure API Key is a string value. You can find it by following Welcome → View/Edit Profile.
product
int M
required
Product Key is very important parameter and you can find it easily followed by My Money → Products →Add A New Product.
cardsend
str D
required
cardsend, a string for default (fixed) value CHECKOUT.
action
str D
required
action, a string for default (fixed) value product.
mode
str D
required
mode, a string for default (fixed) value live. (live or test)
price
dec(10.0.0) M
required
Order Amount, currency format in decimal(10.0.0)
product_name
str M
required
Product Name
ccholder
str C
required
Customer first name
ccholder_lname
str C
required
Customer last name
email
str C
required
Customer billing email
bill_street_1
str C
optional
Customer's shipping street
bill_street_2
str C
optional
Customer's shipping street 2
bill_city
str C
optional
Customer's shipping city
bill_state
str C
optional
Customer's shipping state
bill_country
str C
required
Customer's shipping country
bill_zip
str C
optional
Customer's shipping zip code
bill_phone
str C
required
Customer billing phone
id_order
str M
optional
Merchant’s order ID that will be returned back in a callback.
notify_url
str M
optional
Synchronous notification URL, you can find it in the response data.
success_url
str M
optional
Redirect url of success as per your domain
error_url
str M
optional
Redirect url of error as per your domain

5. Callbacks

Example Request of curl CALLBACK_URL

{
    "transaction_id":"20170928115044",
    "order_id":null,
    "price": 20,
    "fee": 0,
    "currency": "USD",
    "status":"completed",
}

Callback URL can be set in product settings. You will receive the callback parameters via HTTP POST method. All parameters values must be treated as strings.

Parameter Description
transaction_id
bigint(20)
ID of transaction.
order_id
string(64)
Your order ID, if it was provided.
amount
decimal(9,2)
Amount of virtual currency to give to a user.
price
decimal(12,4)
Price of transaction.
currency
string(3)
Currency of transaction. Price, deposit and earned parameters are in this currency.
status
string(16)
Status of a transaction. See the Transaction Status section.
reason
string(255)
May contain a reason for transaction.
sandbox
integer(1)
Represents your product state. Equals 1 if in sandbox, 0 otherwise.

6. Transaction Status

Example of Transaction Status:

//<!--Transaction Status by get method -->
	
curl https://portal.duspay.com/validate.htm?transaction_id=20170928115044

Example of Transaction Status

{
    "status": Completed | Cancelled | Pending
}
Gateway URL https://portal.duspay.com/validate.htm
Method GET
Function Accept credit card payment online from the customers
Remark 1 mandatory parameters only
Parameter Description
transaction_id
int M
required
Transaction ID,a integer and you will use it to login the merchant dashboard. You will find it in the "Transactions List" page. You will find merchant login to View All Transaction → Transaction Id.

7. Objects

Example object

{
    "lastFour": "4242",
    "mask": "************4242",
    "type": "visa",
    "expirationMonth": 1,
    "expirationYear": 2020
}
Parameter Description
lastFour
string
Last four digits of a card number.
mask
string
Card number mask. Only last four digits are visible, others are hidden with asterisks.
type
string
Card type (e.g. visa, mastercard).
expirationMonth
integer
Card expiration month.
expirationYear
integer
Card expiration year.

8. Integration FAQ

Q1. I am getting an error "Your account have not been approved yet. Please contact support@duspay.com for assistance."
Ans.
  1. Merchant Login - My Money → Products → Edit
  2. You must passed the mandatory parameter from the approved URL only. We don’t allow test from any other URL. However test on localhost.
  3. Ensure the Select ID and Select Business URL has been selected while creating the product.
Q2. Should I need to create the product Key for my all product?
Ans.
  1. No
  2. You need to create only one product as per your Select ID and Select Business URL.
  3. Pass the amount parameters and product name dynamically by using the same product key.
Q3. My woo-Commerce plugins is not working?
Ans.
  1. You must create one product from the merchant portal and pass the product key and woo-Commerce parameter by admin of your website.
Q4. What is test card number?
Ans.
  1. 4444 4444 4444 4444     01/2020    123    (4 sixteen times)
  2. 4242 4242 4242 4242     01/2020    123    (42 eight times)
Q5. Can I run this Payment Gateway On Local Host?
Ans.
  1. Yes
  2. You can test on Local Host.
  3. Also, on Approved Business URL.
Q6. How to echo the responce of posted data to duspay via cURL method?
Ans.
  1. You have to use our predefined function of jsonvaluef

9. Shopping Cart Plugins

Wordpress Plugin
    Requirements
    WooCommerce
    Installation
  1. Login to your admin dashboard and navigate to Admin Menu -> Plugins -> Add New -> Search -> DusPay.
  2. Activate the plugin
  3. Navigate to plugin settings page from Admin Menu -> WooCommerce -> Settings -> Checkout -> DusPay.
  4. You can get your keys from here.
OpenCart Extension
    Requirements
    OpenCart
    Installation
  1. Download Extension for your opencart.
  2. Extract the zip file.
  3. put "upload" folder to your website's root directory (Public_html).
  4. Login to your admin dashboard and navigate to Menu -> Extensions -> Payments.(for 2_3_0_2);  or
  5. Login to your admin dashboard and navigate to Menu -> Payments.(for 2_2_0_0)
  6. Find the extension "DusPay" and click on install icon.
  7. After installation click on edit/configure.
  8. Now change "Merchant id" and enter your Secure API Key and Product Key.
  9. You can get your keys from here.
Prestashop Module
    Requirements
    Prestashop
    Installation
  1. Download zip file for your Prestashop.
  2. Login to your admin dashboard and navigate to Menu -> Modules and Services -> Modules and Services -> Add a new module.
  3. Upload zip file you have downloaded.
  4. Search "Credit Card (DusPay.com)" in module list and click install.
  5. If you see a warning message, click on "Proceed with installation".
  6. After installation you will be redirected to configuration page.
  7. Now change "Merchant id" and enter your Secure API Key and Product Key.
  8. You can get your keys from here.
Magento Plugin
    Requirements
    Magento version 1.9
    Installation
  1. Download zip file for your Magento.
  2. Login to your admin dashboard and navigate to Menu -> System -> Magento Connect -> Magento Monncet Manager .
  3. Upload zip file you have downloaded.
  4. Configration login to admin dashboard and navigate to Admin Menu -> System -> Configration -> Duspay.
  5. Now change "Merchant id" and enter your Secure API Key and Product Key.
  6. You can get your keys from here.

    Magento version 2.2
    Installation
  1. Download zip file for your Magento.
  2. Upload the zip file and Extract in cpanel (directory)
  3. Install putty and putty key gen (From google.com)
  4. Create SSH Access in cpanel     (Click here for help...)
  5. Create a password in ssh, Authorize the ssh
  6. Download the private key
  7. Open puttey key gen load here private key (use password which you create in ssh)
  8. Save the private key in putty key gen
  9. Open putty go to ssh-> auth -> uplode private key
  10. Seasion hostname(domain name) ->open
  11. CMD will open put here some command
  12. cpanel user name
    ssh password
    cd public_html (directory)
    php bin/magento setup:upgrade
    php bin/magento setup:static-content:deploy
  13. Configration login to admin dashboard and navigate to admin Menu -> Stores -> Configration -> Sales -> Payment Method -> Duspay.
  14. Now change "Merchant id" and enter your Secure API Key and Product Key. Enabled "Yes", Title "DusPay", Store url "Your domain name", Sandbox "Yes/No".
  15. You can get your keys from here.
WHMCS
    Requirements
    WHMCS
    Installation
  1. Download Extension for your WHMCS.
  2. Extract the zip file.
  3. put "upload" folder to your website's root directory (Public_html).
  4. Login to your admin dashboard and navigate to Menu -> Extensions -> Payments.
  5. Find the extension "DusPay" and click on install icon.
  6. After installation click on edit/configure.
  7. Now change "Merchant id" and enter your Secure API Key and Product Key.
  8. You can get your keys from here.

10. Card

Continue for card details on DusPay.com

Parameter Description
ccno
required
Card number without any separators.
ccvv
required
Card security code (CVC, CVV2).
month
required
Integer representing the card’s expiration month.
year
required
Four digit number representing card’s expiration year.

11. Currency Support

Currency Code
Currency Meaning
CNY
Chinese Yuan
GBP
United Kingdom Pound
USD
United States Dollar
EUR
Euro
CAD
Canadian Dollar
JPY
Japanese Yen
AUD
Australia Dollar
INR
Indian Rupee
HKD
Hong Kong Dollar
IDR
Indonesian Rupiah
MYR
Malaysian Ringgit
MXN
Mexican Peso
SGD
Singapore Dollar

12. Appendix: Order status illustration

Status Code
Meaning
0
Pending
1
Completed
2
Cancelled
3
Refunded
4
Settled
5
Chargeback
6
Returned
7
Completed (Transaction Refunded or Returned)
8
Refund Requested
9
Test Transaction
10
Scrubbed
11
CBK1

13. Appendix: Country Code

14. Appendix: State Code

For the USA and Canada,please use 2 letters state code. Some will require Australia and Japan's state code.

For US:

For Canada(CA):

For Australia(AU):

For Japan(JP):