olaoluwa-98/laravel-payant

用于Payant的Laravel包

安装: 99

依赖: 0

建议: 0

安全: 0

星标: 13

关注者: 4

分支: 1

公开问题: 0

类型:package

1.1.2 2017-08-08 02:21 UTC

This package is not auto-updated.

Last update: 2024-09-29 03:15:29 UTC


README

Latest Stable Version License Build Status Scrutinizer Code Quality Total Downloads

受unicodeveloper的 laravel-paystack 启发

主要功能来自Jonathan Itakpe的 payantNG-php

Laravel 5包,用于与Payant交互

安装

需要PHP 5.4+和Composer

要获取Laravel Payant的最新版本,只需将以下行添加到你的composer.json文件的require块中。

"olaoluwa-98/laravel-payant": "1.1.*"

然后你需要运行composer installcomposer update来下载它并更新自动加载器。

一旦安装了Laravel Payant,你需要注册服务提供者。打开config/app.php并在providers键中添加以下内容。

  • Olaoluwa98\Payant\PayantServiceProvider::class

此外,还可以这样注册外观

'aliases' => [
    ...
    'Payant' => Olaoluwa98\Payant\Facades\Payant::class,
    ...
]

配置

你可以使用以下命令发布配置文件

php artisan vendor:publish --provider="Olaoluwa98\Payant\PayantServiceProvider"

一个名为payant.php的配置文件,其中包含一些合理的默认值,将被放置在你的config目录中

<?php

return [

    /**
     * Public Key From Payant Dashboard
     *
     */
    'public_key' => env('PAYANT_PUBLIC_KEY'),

    /**
     * Private Key From Payant Dashboard
     *
     */
    'private_key' => env('PAYANT_PRIVATE_KEY'),

    /**
     * Payant API MODE
     */
    'mode' => env('PAYANT_MODE'),
];

用法

打开你的.env文件,并添加你的公钥、私钥、演示状态如下:你可以从你的Payant仪表板获取它们

PAYANT_PUBLIC_KEY=xxxxxxxxxxxxx
PAYANT_PRIVATE_KEY=xxxxxxxxxxxxx
PAYANT_MODE= DEMO or LIVE

函数的命名基于位于API文档中的文档。阅读文档中的函数,以了解每个函数所需参数

你可以在控制器中使用包,通过添加use Payant;

$client_data = ['first_name' => 'Emmanuel',
                'last_name' => 'Awotunde',
                'email' => 'awotunde.emmanuel1@gmail.com',
                'phone' => '+2348090579032'];
Payant::addClient($client_data);

如果请求成功,上述函数将返回以下JSON数据

{
  "status": "success",
  "message": "Client created successfully.",
  "data": {
    "company_id": <company_id>,
    "name": "<name>",
    "first_name": "<first_name>",
    "last_name": "<last_name>",
    "email": "<email>",
    "phone": "<phone_no>",
    "website": "<website>",
    "address": "<address>",
    "type": "Customer",
    "settlement_bank": "",
    "account_name": "",
    "account_number": "",
    "status": "1",
    "created_at": "date",
    "updated_at": "date",
    "id": <id_of_client>
  }
}

此包中的函数

  • 杂项
    1. getBanks() [GET]
    2. resolveAccount( array $client_data ) [POST]
  • 客户端
    1. addClient( array $client_data ) [POST]
    2. getClient( $client_id ) [GET]
    3. editClient( $client_id, array $client_data ) [PUT]
    4. deleteClient( $client_id ) [DELETE]
  • 发票
    1. addInvoice( $client_id, array $client_data, $due_date, $fee_bearer, array $items ) [POST]
    2. getInvoice( string $reference_code ) [GET]
    3. sendInvoice( string $reference_code ) [GET]
    4. getInvoiceHistory( $period, $start = null, $end = null ) [POST]
    5. deleteInvoice( string $reference_code ) [DELETE]
  • 转账
    1. addTransfer( array $client_data, string $amount ) [POST]
    2. getTransfer( string $reference_code ) [GET]
    3. getTransferHistory( $period, $start = null, $end = null ) [POST]
    4. deleteTransfer( string $reference_code ) [DELETE]
  • 支付
    1. addPayment( string $reference_code, string $due_date, string $amount, string $channel ) [POST]
    2. getPayment( string $reference_code ) [GET]
    3. getPaymentHistory( string $period, string $start, string $end ) [POST]
    4. deleteTransfer( string $reference_code ) [DELETE]
  • 钱包
    1. addWallet( string $name, string $passcode ) [POST]
    2. getWallet( string $reference_code ) [GET]
    3. changeWalletPasscode( string $reference_code, string $old_passcode, string $passcode ) [PUT]
    4. getWallets() [GET]
    5. setWalletStatus( string $reference_code ) [GET]
    6. withdrawFromWallet( string $reference_code, array $client_data, string $amount, string $passcode ) [POST]
    7. getWalletTransactions( string $reference_code, $period, $start = null, $end = null ) [POST]
  • 产品
    1. addProduct( string $name, string $description, string $unit_cost, string $type ) [POST]
    2. getProduct( $product_id ) [GET]
    3. editProduct( $product_id, array $product_data ) [PUT]
    4. getProducts() [GET]
    5. deleteProduct( $product_id ) [DELETE]

待办事项

  • 添加综合测试

贡献

请随意fork此包,并通过提交pull request来增强功能。

如何感谢您呢?

为什么不给github仓库点个星?我很希望得到关注!为什么不把此仓库的链接分享到Twitter或HackerNews?传播一下!

别忘了在twitter上关注我

谢谢!Emmanuel Awotunde。

许可证

MIT许可证(MIT)。更多信息请参阅许可证文件