Prerequisites
Installation and Usage
Integrating with the PHP SDK requires two steps:
Install the SDK in your project
Initialize the SDK in your application
Step 1: Install the SDK
Install via Composer
To install the SDK, use composer
:
Copy $ composer require indodana-finance/indodana-paylater-sdk
Include the SDK into your PHP file using the autoloader:
Copy <? php
require ( '<YOUR_PROJECT_DIRECTORY>/vendor/autoload.php' );
Step 2: Initialize the SDK
Usage:
Copy <? php
require ( '<YOUR_PROJECT_DIRECTORY>/vendor/autoload.php' );
use Indodana \ Indodana ;
$indodana = new Indodana ([
'apiKey' => '<YOUR_API_KEY>' ,
'apiSecret' => '<YOUR_API_SECRET>' ,
'environment' => 'PRODUCTION' // Optional. Possible value: 'SANDBOX', 'PRODUCTION'. If not set, will default to 'SANDBOX'
]);
Use Case
Get Installment Options
Example:
Copy <? php
require ( '<YOUR_PROJECT_DIRECTORY>/vendor/autoload.php' );
use Indodana \ Indodana ;
$indodana = new Indodana ([
'apiKey' => '<YOUR_API_KEY>' ,
'apiSecret' => '<YOUR_API_SECRET>' ,
'environment' => 'PRODUCTION'
]);
$installmentOptions = $indodana -> getInstallmentOptions ( [
'amount' => 412000 ,
'items' => [
[
'id' => 'MAC1' ,
'name' => 'MacBook Pro' ,
'category' => '<ITEM-CATEGORY>' ,
'price' => 406000 ,
'quantity' => 1 ,
'parentType' => 'SELLER' ,
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
] ,
[
'id' => 'shippingfee' ,
'name' => 'Shipping Fee for Order KXA-1001' ,
'category' => '<ITEM-CATEGORY>' ,
'price' => 10000 ,
'quantity' => 1 ,
'parentType' => 'SELLER' ,
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
] ,
[
'id' => 'taxfee' ,
'name' => 'Tax Fee for Order KXA-1001' ,
'category' => '<ITEM-CATEGORY>' ,
'price' => 20000 ,
'quantity' => 1 ,
'parentType' => 'SELLER' ,
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
] ,
[
'id' => 'discount' ,
'name' => 'Discount for Order KXA-1001' ,
'category' => '<ITEM-CATEGORY>' ,
'price' => 24000 ,
'quantity' => 1 ,
'parentType' => 'SELLER' ,
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
]
]
] ) ;
The array inside getInstallmentOptions
method follows Get Installment Options request body format.
The value of $installmentOptions
follows Get Installment Options response body format.
Checkout
Example:
Copy <? php
require ( '<YOUR_PROJECT_DIRECTORY>/vendor/autoload.php' );
use Indodana \ Indodana ;
$indodana = new Indodana ([
'apiKey' => '<YOUR_API_KEY>' ,
'apiSecret' => '<YOUR_API_SECRET>' ,
'environment' => 'PRODUCTION'
]);
$result = $indodana -> checkout ( [
'transactionDetails' => [
'merchantOrderId' => 'KXA-1001' ,
'amount' => 412000 ,
'items' => [
[
'id' => 'MAC1' ,
'name' => 'MacBook Pro' ,
'category' => '<ITEM-CATEGORY>' ,
'price' => 406000 ,
'quantity' => 1 ,
'parentType' => 'SELLER' ,
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
] ,
[
'id' => 'shippingfee' ,
'name' => 'Shipping Fee for Order KXA-1001' ,
'category' => '<ITEM-CATEGORY>' ,
'price' => 10000 ,
'quantity' => 1 ,
'parentType' => 'SELLER' ,
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
] ,
[
'id' => 'taxfee' ,
'name' => 'Tax Fee for Order KXA-1001' ,
'category' => '<ITEM-CATEGORY>' ,
'price' => 20000 ,
'quantity' => 1 ,
'parentType' => 'SELLER' ,
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
] ,
[
'id' => 'discount' ,
'name' => 'Discount for Order KXA-1001' ,
'category' => '<ITEM-CATEGORY>' ,
'price' => 24000 ,
'quantity' => 1 ,
'parentType' => 'SELLER' ,
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
]
]
] ,
'customerDetails' => [
'firstName' => 'John' ,
'lastName' => 'Doe' ,
'email' => 'johndoe@gmail.com' ,
'phone' => '081277770000'
] ,
'sellers' => [
[
'id' => '32b500ae-6a95-11ea-bc55-0242ac130003' ,
'name' => 'Mac Official Store' ,
'email' => 'admin@macofficialstore.com' ,
'url' => 'www.macofficialstore.com' ,
'address' => [
'firstName' => 'Mac Official Store' ,
'lastName' => '' ,
'address' => 'Jl. M.H Thamrin Boulevard No.22' ,
'city' => 'Tangerang' ,
'postalCode' => '15811' ,
'phone' => '081299991111' ,
'countryCode' => 'IDN'
]
]
] ,
'billingAddress' => [
'firstName' => 'John' ,
'lastName' => 'Doe' ,
'address' => 'Jl. Kyai H. Syahdan No.9, Kel.Palmerah, Kec. Palmerah' ,
'city' => 'Jakarta Barat' ,
'postalCode' => '11480' ,
'phone' => '081277770000' ,
'countryCode' => 'IDN'
] ,
'shippingAddress' => [
'firstName' => 'John' ,
'lastName' => 'Doe' ,
'address' => 'Jl. Kyai H. Syahdan No.9, Kel.Palmerah, Kec. Palmerah' ,
'city' => 'Jakarta Barat' ,
'postalCode' => '11480' ,
'phone' => '081277770000' ,
'countryCode' => 'IDN'
] ,
'paymentType' => '30_days' ,
'approvedNotificationUrl' => 'https://macofficialstore.com/indodanapayment/checkout/approve' ,
'cancellationRedirectUrl' => 'https://macofficialstore.com/indodanapayment/checkout/cancel' ,
'backToStoreUrl' => 'https://macofficialstore.com/indodanapayment/checkout/success'
] ) ;
The array inside checkout
method follows Checkout request body format.
The value of $result
follows Checkout response body format.
Check Transaction Status
Example:
Copy <? php
require ( '<YOUR_PROJECT_DIRECTORY>/vendor/autoload.php' );
use Indodana \ Indodana ;
$indodana = new Indodana ([
'apiKey' => '<YOUR_API_KEY>' ,
'apiSecret' => '<YOUR_API_SECRET>' ,
'environment' => 'PRODUCTION'
]);
$result = $indodana -> checkTransactionStatus ( [
'merchantOrderId' => 'KXA-1001'
] ) ;
The array inside checkTransactionStatus
method follows Check Transaction Status query params format.
The value of $result
follows Check Transaction Status response body format.
Order Cancellation / Refund
Example:
Copy <? php
require ( '<YOUR_PROJECT_DIRECTORY>/vendor/autoload.php' );
use Indodana \ Indodana ;
$indodana = new Indodana ([
'apiKey' => '<YOUR_API_KEY>' ,
'apiSecret' => '<YOUR_API_SECRET>' ,
'environment' => 'PRODUCTION'
]);
$result = $indodana -> refund ( [
'refundId' => 'RFA-1001' ,
'merchantOrderId' => 'KXA-1001' ,
'cancellationAmount' => 412000 ,
'cancellationReason' => 'MAC1 stock is already empty' ,
'cancelledBy' => 'Mac Admin' ,
'cancellationDate' => '2020-03-19T09:53:00+07:00'
] ) ;
The array inside refund
method follows Order Cancellation / Refund request body format.
The value of $result
follows Order Cancellation / Refund response body format.
Last updated 9 months ago