rifkyekayama/faspay-laravel-5 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rifkyekayama/faspay-laravel-5

Composer 安装命令:

composer require rifkyekayama/faspay-laravel-5

包简介

A Laravel package for Faspay Payment Gateway.

README 文档

README

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)

Installation

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

composer require Rifkyekayama/faspay

Configuration

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

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

Finally publish the config file:

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

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

How To Use

After all sets, use this Faspay package as follows:

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

use Rifkyekayama\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 Rifkyekayama\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(\Rifkyekayama\Faspay\Notification $notification) {
    return $notification;
  });
});

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

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.

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.

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2018-03-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固