PHP code example of durianpay / dpay-php
1. Go to this page and download the library: Download durianpay/dpay-php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once ('vendor/autoload.php' );
durianpay / dpay-php example snippets
use Durianpay \Durianpay ;
Durianpay::setApiKey('<YOUR_API_KEY>' );
$res = \Durianpay\Resources\Order::create($body);
$res = \Durianpay\Resources\Order::create(
[
'amount' => '10000' ,
'payment_option' => 'full_payment' ,
'currency' => 'IDR' ,
'order_ref_id' => 'order_ref_001' ,
'customer' => [
'customer_ref_id' => 'cust_001' ,
'given_name' => 'Jane Doe' ,
'email' => 'jane_doe@nomail.com' ,
'mobile' => '85722173217' ,
],
'items' => [
[
'name' => 'LED Television' ,
'qty' => 1 ,
'price' => '10000' ,
'logo' => 'https://merchant.com/product_001/tv_image.jpg' ,
],
]
]
);
var_dump($res);
$res = \Durianpay\Resources\Order::fetch($queryParams);
$res = \Durianpay\Resources\Order::fetch(
[
'from' => '2021-01-01' ,
'to' => '2022-12-31' ,
'skip' => '0' ,
'limit' => '8'
]
);
var_dump($res);
$res = \Durianpay\Resources\Order::fetchOne($id);
$res = \Durianpay\Resources\Order::fetchOne('ord_JYF9EqFOiJ8812' );
var_dump($res);
$res = \Durianpay\Resources\Order::createPaymentLink($body);
$res = \Durianpay\Resources\Order::createPaymentLink(
[
'amount' => '10000' ,
'currency' => 'IDR' ,
'customer' => [
'given_name' => 'John Doe' ,
'email' => 'john_doe@nomail.com' ,
'mobile' => '01234567890' ,
'given_name' => 'John Doe'
],
'items' => [[
'name' => 'LED Television' ,
'qty' => 1 ,
'price' => '10000' ,
'logo' => 'https://merchant.com/product_001/tv_image.jpg'
]]
]
);
var_dump($res);
$res = \Durianpay\Resources\Payment::charge($type, $request);
$type = 'EWALLET' ;
$res = \Durianpay\Resources\Payment::charge($type, [
'order_id' => 'ord_xrc0BvcVIF1680' ,
'wallet_type' => 'DANA' ,
'mobile' => '01234567890' ,
'amount' => '15000'
]);
var_dump($res);
$res = \Durianpay\Resources\Payment::fetch($queryParams);
$res = \Durianpay\Resources\Payment::fetch();
var_dump($res);
$res = \Durianpay\Resources\Payment::fetchOne($id);
$res = \Durianpay\Resources\Order::fetchOne('pay_7UnK1zvIjB5787' );
var_dump($res);
$res = \Durianpay\Resources\Payment::checkStatus($id);
$res = \Durianpay\Resources\Order::checkStatus('pay_7UnK1zvIjB5787' );
var_dump($res);
$res = \Durianpay\Resources\Payment::verify($id, $verificationSignature);
$signature = 'adf9a1a37af514c91225f6680e2df723fefebb7638519bcc7e7c9de02f2a3ab2' ;
$res = \Durianpay\Resources\Order::checkStatus('pay_7UnK1zvIjB5787' , $signature);
var_dump($res);
$res = \Durianpay\Resources\Payment::cancel($id);
$res = \Durianpay\Resources\Order::cancel('pay_7UnK1zvIjB5787' );
var_dump($res);
$res = \Durianpay\Resources\Payment::calculateMDRFees($queryParams);
$res = \Durianpay\Resources\Order::calculateMDRFees(['amount' => '50000' ]);
var_dump($res);
use Durianpay \Exceptions \BadRequestException ;
try {
} catch (BadRequestException $error) {
$errorDesc = $error->getDetailedErrorDesc();
echo $error;
var_dump($errorDesc);
}
bash
composer