PHP code example of ferdhika31 / ipaymu-php

1. Go to this page and download the library: Download ferdhika31/ipaymu-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ferdhika31 / ipaymu-php example snippets



use ferdhika31\iPaymuPHP\iPaymu;

$config = [
    'env'               => 'SANDBOX', // SANDBOX or PRODUCTION
    'virtual_account'   => 'your_virtual_account',
    'api_key'           => 'your_api_key',
    'notify_uri'        => 'http://localhost:8000/notify',
    // for redirect payment is 


use ferdhika31\iPaymuPHP\Balance;

$getBalance = Balance::getBalance();


$customer = [
    'name' => 'Dika',
    'email' => '[email protected]',
    'phone' => '083213123332'
];
iPaymu::setCustomer($customer);


iPaymu::addProduct([
    'name'          => 'Mangga',
    'qty'           => 2,
    'price'         => 2500,
    'description'   => 'Mangga cobian'
]);
iPaymu::addProduct([
    'name'          => 'Jeruk',
    'qty'           => 1,
    'price'         => 1500,
    'description'   => 'Jeruk haseum'
]);


use ferdhika31\iPaymuPHP\PaymentRedirect;

// optional
$payloadTrx = [
    'expired' => 1, // in hours
    'comments' => 'Transaction comment here',
    'referenceId' => 'TRX202008310001'
];

$redirectPayment = PaymentRedirect::create($payloadTrx);


use ferdhika31\iPaymuPHP\PaymentRedirect;

// optional
$payloadTrx = [
    'expired' => 1, // in hours
    'comments' => 'Transaction comment here',
    'referenceId' => 'TRX202008310001'
];

$redirectPayment = PaymentRedirect::mandiriVA()->create($payloadTrx);
$redirectPayment = PaymentRedirect::niagaVA()->create($payloadTrx);
$redirectPayment = PaymentRedirect::BNIVA()->create($payloadTrx);
$redirectPayment = PaymentRedirect::BAGVA()->create($payloadTrx);
$redirectPayment = PaymentRedirect::BCATransfer()->create($payloadTrx);
$redirectPayment = PaymentRedirect::QRIS()->create($payloadTrx);
$redirectPayment = PaymentRedirect::CStore()->create($payloadTrx);
$redirectPayment = PaymentRedirect::creditCard()->create($payloadTrx);
$redirectPayment = PaymentRedirect::COD()->create($payloadTrx);
$redirectPayment = PaymentRedirect::akulaku()->create($payloadTrx);


use ferdhika31\iPaymuPHP\PaymentDirect;

$payloadTrx = [
    'amount' => 5000,
    // optional
    'expired' => 10,
    'expiredType' => 'minutes', // in:seconds,minutes,hours,days
    'comments' => 'Transaction comment here',
    'referenceId' => 'TRX202008310001'
];

// Available channel Virtual Account : bag, bni, cimb (default), mandiri
$channel = 'mandiri';
$directPayment = PaymentDirect::VA($channel)->create($payloadTrx);

// Available channel Transfer Bank : bca (default)
$channel = 'bca';
$directPayment = PaymentDirect::bankTransfer($channel)->create($payloadTrx);

// Available channel Convenience Store : indomaret (default), alfamart
$channel = 'alfamart';
$directPayment = PaymentDirect::cStore($channel)->create($payloadTrx);

// Available channel: linkaja (default)
$channel = 'linkaja';
$directPayment = PaymentDirect::QRIS($channel)->create($payloadTrx);


use ferdhika31\iPaymuPHP\Transaction;

$id = 27958;
$getTrx = Transaction::getById($id);

composer 
bash
php examples\CheckBalanceExample.php