PHP code example of thearkaid / laravel-faspay

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

    

thearkaid / laravel-faspay example snippets


  /**
   * Set true saat dalam Mode Development
   * Set false saat ke Mode Production
   */
  'isdev' => true,
  // Kredensial saat dalam Mode Development
  'devcred' => [
      'merchantname' => env('FP_DEV_MERCHANT_NAME', 'OR JUST SET HERE'),
      'merchantid' => env('FP_DEV_MERCHANT_ID', 'OR JUST SET HERE'),
      'userid' => env('FP_DEV_USER_ID', 'OR JUST SET HERE'),
      'password' => env('FP_DEV_PASSWORD', 'OR JUST SET HERE'),
      'redirecturl' => env('FP_DEV_REDIRECT_URL', 'OR JUST SET HERE')
  ],
  // Kredensial saat dalam Mode Production
  'prodcred' => [
      'merchantname' => env('FP_PROD_MERCHANT_NAME', 'OR JUST SET HERE'),
      'merchantid' => env('FP_PROD_MERCHANT_ID', 'OR JUST SET HERE'),
      'userid' => env('FP_PROD_USER_ID', 'OR JUST SET HERE'),
      'password' => env('FP_PROD_PASSWORD', 'OR JUST SET HERE'),
      'redirecturl' => env('FP_PROD_REDIRECT_URL', 'OR JUST SET HERE')
  ]

  // Require LaravelFaspay class
  use TheArKaID\LaravelFaspay\LaravelFaspay;

  // Create an object from LaravelFaspay Class
  $faspayer = new LaravelFaspay();

  // Return Payment Channel here
  return $faspayer->getPaymentChannel();

  // Define your payment channel,
  $paymentChannel['pg_code'] = "802";
  $paymentChannel['pg_name'] = "Mandiri Virtual Account";
    
  // Create an array for ordered Item
  $item = Array();
  $order["product"] = "Item #1"; // Product Name
  $order["qty"] = 1; // QTY
  $order["amount"] = 100000; // Price. Just the real price, without any '.'(dot) or ',' (comma).
  $order["paymentplan"] = 1; // Payment Plan. See References below.
  $order["merchantid"] = $faspayer->getConfig()->getUser()->getMerchantId(); // Merchant ID
  $order["tenor"] = 00; // Tenor. See References below.
  array_push($item, $order); // Push order,
  // Loop or push again for more than 1 items.

  // Create Bill Data
  $billData["billno"] = "1232123"; // Bill Number
  $billData["billdesc"] = "Pembayaran RHI"; // Billing Description
  $billData["billexp"] = 2; // Expired Day Interval (in total days)
  $billData["billtotal"] = 10000; // Bill Total, Just the real bill, without any '.'(dot) or ',' (comma).
  $billData["paytype"] = 3 // Pay Type. See References below.

    // Create User Data
  $userData["phone"] = "087123123123"; // Phone Number
  $userData["email"] = "[email protected]"; // Email
  $userData["terminal"] = 21; // Terminal
  $userData["custno"] = "12345"; // Customer No
  $userData["custname"] = "thearka"; // Customer Name

  // Proccess the request and return the result.
  return $faspayer->createPayment($item, $paymentChannel, $billData, $userData);

  // Proccess the request and return the result.
  return $faspayer->checkPaymentStatus(
    $reqdesc, // Request Description
    $trx_id, // Transaction ID
    $billno // Billing Number
   );

  // Proccess the request and return the result.
  return $faspayer->cancelPayment(
    $trx_id, // Transaction ID
    $billno, // Billing Number
    $paymentcancel // Description for Cancellation
   );

  // Get the notification.
  return $faspayer->notifier();

  // The Data returned. Take the data for updating your data status. 
  // Success.
  {
    "response": "Payment Notification",
    "response_date": "2020-06-28 17:06:26",
    "trx_id": "1234567890", // Transaction ID
    "merchant_id": "12345", // Merchant ID
    "merchant": "TheArKa", // Merchant Name
    "response_code": "00",
    "response_desc": "Sukses"
  }

  // Failed
  {
    "response": "Payment Notification",
    "response_date": "2020-06-28 17:06:15",
    "trx_id": "1234567890", // Transaction ID
    "merchant_id": "12345", // Merchant ID
    "merchant": "TheArKa", // Merchant Name
    "response_code": "01",
    "response_desc": "Gagal"
  }

  // Get the callback data
  return $faspayer->callbacker();
  // The Data returned. Take the data for updating your data status. 
  {
    "response": "Callback",
    "response_date": "2020-06-28 17:06:26",
    "trx_id": "1234567890", // Transaction ID
    "bill_no": "1234567890", // Bill Number
    "merchant_id": "12345", // Merchant ID
    "merchant": "TheArKa", // Merchant Name
    "bill_ref": "1234567890", // Bill Reference
    "response_code": "00",
    "response_desc": "Sukses"
  }


php artisan vendor:publish --provider='TheArKaID\LaravelFaspay\Providers\LaravelFaspayServiceProvider'