This is the Official PHP wrapper/library for iPaymu Payment API, that is compatible with Composer. Visit https://ipaymu.com for more information about the product and see documentation at https://ipaymu.com/en/api-documentation/ for more technical details.
Free signup here https://my.ipaymu.com/members/signup.htm to accept payment online now!
The best way to use this package is using composer
composer require ipaymu/ipaymu-php-api
First, get your apikey & va number from iPaymu dashboard.
<?php
use iPaymu\iPaymu;
$apiKey = 'your-apikey';
$va = 'your-va';
$production = true;
$iPaymu = new iPaymu($apiKey, $va, $production);
$balance = $iPaymu->checkBalance();
$status = $iPaymu->checkTransaction($id);
$iPaymu->setURL([
'ureturn' => 'https://your-website/thankyou_page',
'unotify' => 'https://your-website/notify_page',
'ucancel' => 'https://your-website/cancel_page',
]);
$buyer = $iPaymu->setBuyer([
'name' => 'your-name',
'phone' => 'your-phone',
'email' => 'your-email',
]);
There are 2 payment methods: Payment Direct & Payment Redirect, with the following parameters:
Parameter Request | Description | Type | Mandatory |
---|---|---|---|
account | VA Number | numeric | Y |
name | Customer Name | string | Y |
Customer E-mail | string | Y | |
phone | Customer Phone | numeric | Y |
amount | Total Amount (price * qty) | numeric | Y |
paymentMethod | va, cstore, cod, qris | string | Y |
paymentChannel | "va:" bag, bca, bni, cimb, mandiri, bmi, bri, bsi, permata, danamon "cstore:" indomaret, alfamart "cod:" rpx "qris:" qris | string | Y |
notifyUrl | Return url when payment success | string | Y |
expired | Expiration in hour | numeric | N |
description | Text description | string | N |
referenceId | Shopping cart order id | string | N |
product | Product Name | [array] string | Y |
qty | Quantity | [array] numeric | Y |
price | Product Price | [array] numeric | Y |
weight | Product Weight | [array] numeric | Y |
length | Product Length | [array] numeric | Y |
width | Product Width | [array] numeric | Y |
height | Product Height | [array] numeric | Y |
deliveryArea | Postal Code Customer | numeric | Y |
deliveryAddress | Customer Address | string | Y |
pickupArea | Postal Code Shipper (Default Merchant Postal Code) | numeric | N |
pickupAddress | Shipper Address (Default Merchant Address) | string | N |
First, please add product to shopping cart first before using this method
$carts = [];
$carts = $iPaymu->add(
'PROD0001', // product id (string)
'Jacket', // product name (string)
12000, // price (float)
2, // quantity (int)
'Size M', // description
1, // product weight (int) (optional)
1, // product length (int) (optional)
1, // product weight (int) (optional)
1 // product height (int) (optional)
);
$carts = $iPaymu->add(
'PROD0002', // product id (string)
'Shoe', // product name (string)
150000, // price (float)
2, // quantity (int)
'Size 8', // description
1, // product weight (int) (optional)
1, // product length (int) (optional)
1, // product weight (int) (optional)
1 // product height (int) (optional)
);
$iPaymu->addCart($carts);
$delivery = $iPaymu->setCOD([
'deliveryArea' => "76111",
'deliveryAddress' => "Denpasar",
]);
// set your expiredPayment
$iPaymu->setExpired(24, 'hours'); // 24 hours
$iPaymu->setReferenceId('123123');
$iPaymu->setComments('Payment TRX01');
Payment direct method allows you to accept payment on your checkout page directly, this method works for any payment channel except for credit card.
Set Payment Method and Payment Channel
// set payment method
// check https://ipaymu.com/api-collection for list payment method
$iPaymu->setPaymentMethod('va');
// check https://ipaymu.com/api-collection for list payment channel
$iPaymu->setPaymentChannel('bca');
$payment = $iPaymu->directPayment();
In order accepting credit card, you must use Payment Redirect method. Upon checkout, you will be redirected to iPaymu.com payment page for further payment processing.
$payment = $iPaymu->redirectPayment();
Direct Payment Example
$apiKey = 'QbGcoO0Qds9sQFDmY0MWg1Tq.xtuh1'; // your api key
$va = '1179000899'; // your va
$production = true; // set false to sandbox mode
$iPaymu = new iPaymu($apiKey, $va, $production);
// set callback url
$iPaymu->setURL([
'ureturn' => 'https://your-website/thankyou_page',
'unotify' => 'https://your-website/notify_page',
'ucancel' => 'https://your-website/cancel_page',
]);
// set buyer name
$iPaymu->setBuyer([
'name' => 'Bagus',
'phone' => '08123123139',
'email' => 'bagus@gmail.com',
]);
// set your reference id (optional)
$iPaymu->setReferenceId('123123');
// set your expiredPayment
$iPaymu->setExpired(24, 'hours'); // 24 hours
// set payment method
// check https://ipaymu.com/api-collection for list payment method
$iPaymu->setPaymentMethod('va');
// check https://ipaymu.com/api-collection for list payment channel
$iPaymu->setPaymentChannel('bca');
// payment notes (optional)
$iPaymu->setComments('Payment TRX01');
$carts = [];
$carts = $iPaymu->add(
'PROD0001', // product id (string)
'Jacket', // product name (string)
12000, // price (float)
3, // quantity (int)
'Size M', // description
1, // product weight (int) (optional)
1, // product length (int) (optional)
1, // product weight (int) (optional)
1 // product height (int) (optional)
);
$carts = $iPaymu->add(
'PROD0002', // product id (string)
'Shoe', // product name (string)
150000, // price (float)
2, // quantity (int)
'Size 8', // description
1, // product weight (int) (optional)
1, // product length (int) (optional)
1, // product weight (int) (optional)
1 // product height (int) (optional)
);
$iPaymu->addCart($carts);
return $iPaymu->directPayment();
Redirect Payment Example
$apiKey = 'QbGcoO0Qds9sQFDmY0MWg1Tq.xtuh1'; // your api key
$va = '1179000899'; // your va
$production = true; // set false to sandbox mode
$iPaymu = new iPaymu($apiKey, $va, $production);
// set callback url
$iPaymu->setURL([
'ureturn' => 'https://your-website/thankyou_page',
'unotify' => 'https://your-website/notify_page',
'ucancel' => 'https://your-website/cancel_page',
]);
// set buyer name
$iPaymu->setBuyer([
'name' => 'Bagus',
'phone' => '08123123139',
'email' => 'bagus@gmail.com',
]);
// set your reference id (optional)
$iPaymu->setReferenceId('123123');
// set your expiredPayment
$iPaymu->setExpired(24, 'hours'); // 24 hours
// set cod param (optional)
$iPaymu->setCOD([
'deliveryArea' => "76111",
'deliveryAddress' => "Denpasar",
]);
$carts = [];
$carts = $iPaymu->add(
'PROD0001', // product id (string)
'Jacket', // product name (string)
12000, // price (float)
2, // quantity (int)
'Size M', // description
1, // product weight (int) (optional)
1, // product length (int) (optional)
1, // product weight (int) (optional)
1 // product height (int) (optional)
);
$carts = $iPaymu->add(
'PROD0002', // product id (string)
'Shoe', // product name (string)
150000, // price (float)
2, // quantity (int)
'Size 8', // description
1, // product weight (int) (optional)
1, // product length (int) (optional)
1, // product weight (int) (optional)
1 // product height (int) (optional)
);
$iPaymu->addCart($carts);
return $iPaymu->redirectPayment();