Integrate with PHP SDK

Prerequisites

Installation and Usage

Integrating with the PHP SDK requires two steps:

  1. Install the SDK in your project

  2. Initialize the SDK in your application

Step 1: Install the SDK

Install via Composer

To install the SDK, use composer:

$ composer require indodana/indodana-paylater-sdk

Include the SDK into your PHP file using the autoloader:

<?php
require('<YOUR_PROJECT_DIRECTORY>/vendor/autoload.php');

Step 2: Initialize the SDK

Usage:

<?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:

<?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',
'price' => 406000,
'quantity' => 1,
'parentType' => 'SELLER',
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
],
[
'id' => 'shippingfee',
'name' => 'Shipping Fee for Order KXA-1001',
'price' => 10000,
'quantity' => 1,
'parentType' => 'SELLER',
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
],
[
'id' => 'taxfee',
'name' => 'Tax Fee for Order KXA-1001',
'price' => 20000,
'quantity' => 1,
'parentType' => 'SELLER',
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
],
[
'id' => 'discount',
'name' => 'Discount for Order KXA-1001',
'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:

<?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',
'price' => 406000,
'quantity' => 1,
'parentType' => 'SELLER',
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
],
[
'id' => 'shippingfee',
'name' => 'Shipping Fee for Order KXA-1001',
'price' => 10000,
'quantity' => 1,
'parentType' => 'SELLER',
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
],
[
'id' => 'taxfee',
'name' => 'Tax Fee for Order KXA-1001',
'price' => 20000,
'quantity' => 1,
'parentType' => 'SELLER',
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
],
[
'id' => 'discount',
'name' => 'Discount for Order KXA-1001',
'price' => 24000,
'quantity' => 1,
'parentType' => 'SELLER',
'parentId' => '32b500ae-6a95-11ea-bc55-0242ac130003'
]
]
],
'customerDetails' => [
'firstName' => 'John',
'lastName' => 'Doe',
'email' => '[email protected]',
'phone' => '081277770000'
],
'sellers' => [
[
'id' => '32b500ae-6a95-11ea-bc55-0242ac130003',
'name' => 'Mac Official Store',
'email' => '[email protected]',
'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:

<?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:

<?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.