PHP code example of steevenz / ipaymu

1. Go to this page and download the library: Download steevenz/ipaymu 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/ */

    

steevenz / ipaymu example snippets


use Steevenz\Ipaymu;

/*
 * --------------------------------------------------------------
 * Inisiasi Class Ipaymu
 * --------------------------------------------------------------
 */
 // Untuk menggunakan API Ipaymu Account saja.
 $ipaymu = new Ipaymu();
 $ipaymu->setApiKey('API_KEY_ANDA');
 
 // Untuk menggunakan API Ipaymu Account dan Webstore.
 $ipaymu = new Ipaymu([
    'apiKey' => 'API_KEY_ANDA',
    
    // Konfigurasi Url diperlukan untuk melakukan transaksi ke ipaymu
    'url' => [
        'return' => 'http://www.domainanda.com/terimakasih.html'
        'notify' => ' http://www.domainanda.com/notify-ipaymu.php'
        'cancel' => 'http://www.domainanda.com/batal.html'
    ]
 ]);
 
/*
 * --------------------------------------------------------------
 * Mendapatkan informasi akun Ipaymu
 * 
 * @return array
 * --------------------------------------------------------------
 */
$account = $ipaymu->getAccount();

/*
 * --------------------------------------------------------------
 * Cek Saldo Akun
 * Untuk mengecek jumlah saldo terakhir Anda.
 *
 * @return int
 * --------------------------------------------------------------
 */
$balance = $ipaymu->checkAccountBalance();

/*
 * --------------------------------------------------------------
 * Cek Status Akun
 * Untuk mengecek status akun iPaymu.
 *
 * @return string
 * --------------------------------------------------------------
 */
$status = $ipaymu->checkAccountStatus();

/*
 * --------------------------------------------------------------
 * Cek Transaksi
 *
 * @param string $trxId Kode Unik Transaksi.
 * @return array|bool Returns FALSE if failed.
 * --------------------------------------------------------------
 */
$transaction = $ipaymu->checkTransaction('IDX-1234567890');

/*
 * --------------------------------------------------------------
 * Melakukan transaksi pembayaran dengan single produk
 *
 * @return array|bool   Returns FALSE if failed or returns array contains
 *                      Ipaymu transaction Url.
 * --------------------------------------------------------------
 */
$ipaymu->addTransaction([
   'id' => 'INV-1234567890',
   'product' => [
       'name' => 'Shoes'
       'price' => 10000,
       'quantity' => 1,
       'description' => 'Amazing Shoes'
   ]
]);

/*
 * --------------------------------------------------------------
 * Melakukan transaksi pembayaran PayPal dengan single produk
 * 
 * @return array|bool   Returns FALSE if failed or returns array contains
 *                      Ipaymu transaction Url.
 * --------------------------------------------------------------
 */
$ipaymu->addTransaction([
   'id' => 'INV-1234567890',
   'product' => [
       'name' => 'Shoes'
       'price' => 10000,
       'price_usd' => 1, // Wajib menyertakan harga dalam kurs USD
       'quantity' => 1,
       'description' => 'Amazing Shoes'
   ]
], '[email protected]');

/*
 * --------------------------------------------------------------
 * Melakukan transaksi pembayaran dengan multi produk
 * 
 * @return array|bool   Returns FALSE if failed or returns array contains
 *                      Ipaymu transaction Url.
 * --------------------------------------------------------------
 */
 $ipaymu->addTransaction([
      'id' => 'INV-1234567890',
      'products' => [
          [
              'name' => 'Shoes',
              'price' => 10000,
              'quantity' => 1,
              'description' => 'Amazing Shoes'
          ],
          [
              'name' => 'Bag',
              'price' => 5000,
              'quantity' => 2,
              'description' => 'Amazing Bag'
          ]
      ]
 ]);
 
 /*
  * --------------------------------------------------------------
  * Melakukan transaksi pembayaran PayPal dengan multi produk
  * 
  * @return array|bool   Returns FALSE if failed or returns array contains
  *                      Ipaymu transaction Url.
  * --------------------------------------------------------------
  */
  $ipaymu->addTransaction([
       'id' => 'INV-1234567890',
       'products' => [
           [
               'name' => 'Shoes',
               'price' => 10000,
               'price_usd' => 1, // Wajib menyertakan harga dalam kurs USD
               'quantity' => 1,
               'description' => 'Amazing Shoes'
           ],
           [
               'name' => 'Bag',
               'price' => 5000,
               'price_usd' => 1, // Wajib menyertakan harga dalam kurs USD
               'quantity' => 2,
               'description' => 'Amazing Bag'
           ]
       ]
  ], '[email protected]');

/*
 * --------------------------------------------------------------
 * Mendapatkan original response object.
 * --------------------------------------------------------------
 */
 $response = $ipaymu->getResponse();
 
/*
 * --------------------------------------------------------------
 * Mendapatkan informasi error.
 * --------------------------------------------------------------
 */
 $errors = $ipaymu->getErrors();