Paylater by Indodana Finance
  • Homepage
  • Getting Started
    • Introduction
    • Preparation
  • Merchant Operations
    • Settlement Report
    • Merchant Dashboard
    • Getting Paid
    • Dispute Resolutions
    • Frequently Asked Questions (FAQ)
  • Marketing
    • Guideline and Compliance
  • API Reference
    • Online Transaction API
    • QuickPay Transaction API*
    • PoS Transaction API
  • Integration
    • Direct API Integration
    • QRIS API Integration
    • Integrate with E-commerce Plugins
    • Integrate with PHP SDK
  • Go-Live Preparation
    • Whitelist IP
    • Testing Credentials
    • UAT Integration
    • Developer Help
Powered by GitBook
On this page
  • Prerequisites
  • Installation and Usage
  • Step 1: Install the SDK
  • Step 2: Initialize the SDK
  • Use Case
  • Get Installment Options
  • Checkout
  • Check Transaction Status
  • Order Cancellation / Refund
  1. Integration

Integrate with PHP SDK

PreviousIntegrate with E-commerce PluginsNextWhitelist IP

Last updated 5 months ago

Prerequisites

  • PHP 5.6 or above

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-finance/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',
          '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'
    ]
    ]
]);

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',
                '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'
]);

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'
]);

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 getInstallmentOptions method follows format.

The value of $installmentOptions follows format.

The array inside checkout method follows format.

The value of $result follows format.

The array inside checkTransactionStatus method follows format.

The value of $result follows format.

The array inside refund method follows format.

The value of $result follows format.

API credentials
Composer
Get Installment Options request body
Get Installment Options response body
Checkout request body
Checkout response body
Check Transaction Status query params
Check Transaction Status response body
Order Cancellation / Refund request body
Order Cancellation / Refund response body