For full documentations regarding Durianpay APIs, visit our docs.
If you already set up composer
in your project, then type the command below:
composer require durianpay/dpay-php
Set up the SDK by passing your dashboard API key to Durianpay class.
use Durianpay\Durianpay;
Durianpay::setApiKey('<YOUR_API_KEY>');
To find your API key, go to your dashboard settings and click on API keys.
For detailed information regarding Order APIs, visit our docs.
$res = \Durianpay\Resources\Order::create($body);
Pass order details to function.
Example call:
$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);
Note: Passing $queryParams
is optional. If limit
property is not specified in the $queryParams
, then the SDK immediately limits the amount of orders returned to the five latest ones.
Example call:
$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);
Pass order id as an argument to the function.
Example call:
$res = \Durianpay\Resources\Order::fetchOne('ord_JYF9EqFOiJ8812');
var_dump($res);
$res = \Durianpay\Resources\Order::createPaymentLink($body);
Pass order details to function. This function will automatically append property 'is_payment_link' => true
to the request body.
Example call:
$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);
For detailed information regarding Payment APIs, visit our docs.
$res = \Durianpay\Resources\Payment::charge($type, $request);
Pass order details to function.
Example call:
$type = 'EWALLET'; // EWALLET, VA, RETAILSTORE, ONLINE_BANKING, BNPL, or QRIS
$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);
Note: Passing $queryParams
is optional. If limit
property is not specified in the $queryParams
, then the SDK immediately limits the amount of payments returned to the five latest ones.
Example call:
$res = \Durianpay\Resources\Payment::fetch();
var_dump($res);
$res = \Durianpay\Resources\Payment::fetchOne($id);
Pass payment id as an argument to the function.
Example call:
$res = \Durianpay\Resources\Order::fetchOne('pay_7UnK1zvIjB5787');
var_dump($res);
$res = \Durianpay\Resources\Payment::checkStatus($id);
The function will return the current state of the payment (completed, processing, cancelled, or failed).
Example call:
$res = \Durianpay\Resources\Order::checkStatus('pay_7UnK1zvIjB5787');
var_dump($res);
$res = \Durianpay\Resources\Payment::verify($id, $verificationSignature);
Example call:
$signature = 'adf9a1a37af514c91225f6680e2df723fefebb7638519bcc7e7c9de02f2a3ab2';
$res = \Durianpay\Resources\Order::checkStatus('pay_7UnK1zvIjB5787', $signature);
var_dump($res);
$res = \Durianpay\Resources\Payment::cancel($id);
Will immediately set the payment status to cancelled.
Example call:
$res = \Durianpay\Resources\Order::cancel('pay_7UnK1zvIjB5787');
var_dump($res);
$res = \Durianpay\Resources\Payment::calculateMDRFees($queryParams);
Example call:
$res = \Durianpay\Resources\Order::calculateMDRFees(['amount' => '50000']);
var_dump($res);
We are continuously expanding this documentation, so stay tune for more features. Meanwhile, you can explore our docs first at https://durianpay.id/docs.
Our SDK comes with various exception handlers. Whenever you call a function, it is recommended to always wrap it inside a try-catch
block.
use Durianpay\Exceptions\BadRequestException;
try {
// Some Durianpay functions
} catch(BadRequestException $error) {
$errorDesc = $error->getDetailedErrorDesc();
echo $error;
var_dump($errorDesc);
}