2017 © Pedro Peláez
 

library faspay

A Laravel Package For Faspay Payment Gateway

image

krisnasw/faspay

A Laravel Package For Faspay Payment Gateway

  • Monday, August 28, 2017
  • by Krisnasw
  • Repository
  • 2 Watchers
  • 4 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Faspay Payment Gateway Package for Laravel 5

Use Faspay as your payment gateway for your project? Then this package is for you. This is a laravel package to communicate with Faspay Payment Gateway API (currently only support DEBIT API), (*1)

Installation

To get started with Faspay, run this command or add the package to your composer.json, (*2)

composer require krisnasw/faspay dev-master

Configuration

After installing the Faspay package, register the Krisnasw\Faspay\FaspayServiceProvider in your config/app.php file. Also, add the Faspay and Payment facade to the aliases array in your app configuration file:, (*3)

'Faspay' => Krisnasw\Faspay\Facades\Faspay::class,
'Payment' => Krisnasw\Faspay\Facades\Payment::class,

Finally publish the config file:, (*4)

php artisan vendor:publish --provider="Krisnasw\Faspay\FaspayServiceProvider"

and change merchant_id, merchant_name, user_id, and password in the config/faspay.php with yours., (*5)

How To Use

After all sets, use this Faspay package as follows:, (*6)

// Customer class example. You can apply to any model you want.

use Krisnasw\Faspay\CustomerInterface;

class Customer implements CustomerInterface
{
  public function getFaspayCustomerNumber()
  {
    return 'customer-number';
  }

  public function getFaspayCustomerName()
  {
    return 'customer-name';
  }

  public function getFaspayCustomerEmail()
  {
    return 'customer-email';
  }

  public function getFaspayCustomerPhone()
  {
    return 'customer-phone';
  }

  public function getFaspayPreferredCurrency()
  {
    return 'customer-currency';
  }
}
// Item class example. You can apply to any model you want.

use Krisnasw\Faspay\Payable;

class Item implements Payable
{
  public function getPayableName()
  {
    return 'Product Name';
  }

  public function getPayablePrice()
  {
    return 300000;
  }
}
// An example how to use the API.

Route::get('/', function () {

  $customer = new Customer();
  $payable = new Item();

  $payment = Payment::performedBy($customer)
    ->via('web')
    ->payWith('tcash')
    ->addTax(10)
    ->addMiscFee(1000);

  $payment->addItem($payable, 2);

  $response = Faspay::registerPayment($payment);

  return Faspay::redirectToPay($payment);
});

Route::get('/callback-notif', function(\Illuminate\Http\Request $request) {
  return Faspay::notified($request, function(\Krisnasw\Faspay\Notification $notification) {
    return $notification;
  });
});

To generate a custom billing number/code, you can create a class that implements BillingProfileInterface, for example:, (*7)

class TopupBillingProfile implements BillingProfileInterface
{
  public function description()
  {
    return 'Topup Saldo'; 
  }

  public function generate(Payment $payment)
  {
    return str_random(15);
  }
}

and then pass it as a second argument of registerPayment() method., (*8)

Bugs & Improvements

This package is far from perfect. It doesn't support BCA KlikPay yet. It doesn't support Faspay Credit API also. Feel free to report me any bug you found or send me pull requests., (*9)

The Versions

28/08 2017

dev-master

9999999-dev

A Laravel Package For Faspay Payment Gateway

  Sources   Download

MIT

The Requires

 

28/08 2017

v1.0.0

1.0.0.0

A Laravel Package For Faspay Payment Gateway

  Sources   Download

MIT

The Requires