phalconvee/laravel-paga

Paga 使企业接受支付变得非常简单。这个业务服务库是一个 Laravel/PHP 模块,帮助您在处理 Paga 业务交易时进行 API 调用。

v1.0.0 2021-01-21 23:14 UTC

This package is auto-updated.

Last update: 2024-09-23 07:55:46 UTC


README

Latest Version on Packagist Packagist License Build Status Quality Score Total Downloads

一个用于操作 Paga 业务 API 的 Laravel 扩展包。

安装

需要 PHP 5.4+ 和 Composer

您可以通过 composer 获取 Laravel Paga 的最新版本。

composer require phalconvee/laravel-paga

您需要运行 compser installcomposer update 来下载它并更新自动加载器。

安装 Laravel Paga 后,您需要注册服务提供者。打开 config/app.php 并将以下内容添加到 providers 键中

'providers' => [
    ...
    Phalconvee\Paga\PagaServiceProvider::class,
    ...
]

如果您使用 Laravel >= 5.5,则可以跳过此步骤,直接转到 配置

  • Phalconvee\Paga\PagaServiceProvider::class

此外,还可以这样注册 Facade

'aliases'=>[ 
    ...
    'Paga' => Phalconvee\Paga\Facades\Paga::class
    ...
]

配置

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

php artisan vendor:publish --provider="Phalconvee\Paga\PagaServiceProvider"

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

<?php
return [

    /**
     * API Key From Paga Dashboard
     */
    'apiKey' => env('PAGA_HMAC_API_KEY'),

    /**
     * Public Key From Paga Dashboard
     */
    'publicKey' => env('PAGA_PUBLIC_KEY'),

    /**
     * Secret Key / Credentials From Paga Dashboard
     */
    'secretKey' => env('PAGA_SECRET_KEY')

];

由该包公开的业务服务

  • getBanks
  • getMerchants
  • getMerchantServices
  • getMobileOperators
  • getOperationStatus
  • accountBalance
  • airtimePurchase
  • depositToBank
  • validateDepositToBank
  • moneyTransfer
  • moneyTransferBulk
  • onboardMerchant
  • merchantPayment
  • transactionHistory
  • recentTransactionHistory
  • registerCustomer
  • validateCustomer

使用

打开您的 .env 文件,并添加如下所示的 api 密钥、公钥和密钥/凭据

PAGA_HMAC_API_KEY=xxxxxxxxxxxxxx
PAGA_PUBLIC_KEY=xxxxxxxxxxxxxx
PAGA_SECRET_KEY=xxxxxxxxxxxxxx

如果您使用的是 AWS、heroku 等托管服务,请确保将上述详细信息分别添加到环境变量和配置变量中。

1. 前提条件

确认您的服务器可以与 Paga 服务器建立 TLSv1.2 连接。大多数最新的软件都具备此功能。如果您遇到任何 SSL 错误,请联系您的服务提供商以获取指导。不要禁用 SSL 伙伴验证!

2. 初始化服务器环境

在 Paga 上执行任务时,您需要初始化您打算运行请求的服务器环境。

有测试环境(test)和实时环境(live)。您的凭据将经过您初始化的环境进行验证。

建议在使用此包中的控制器类时,在构造函数中初始化此环境。

<?php
    
    use Phalconvee\Paga\Facades\Paga;
    
    class MyExampleController extends Controller
    {
        public function __construct()
        {
            Paga::setTest(true); // passing false (boolean) sets environment to live.
        }
    }

此包还提供了流畅的方法。请参阅以下内容。

/**
* This method generates a unique secure cryptographic hash token to use as transaction reference.
* @returns string
*/
Paga::getTransactionReference();

/** Alternatively, use the helper */    
paga()->getTransactionReference();

/**
* This method returns list of banks integrated with Paga.
* @returns array
*/
Paga::getBanks();

/** Alternatively, use the helper */    
paga()->getBanks();

/**
* This method returns list of merchants integrated with Paga.
* @returns array 
*/
Paga::getMerchants();

/** Alternatively, use the helper */    
paga()->getMerchants();

/**
* This method returns list of merchants services registered on Paga.
* @returns array 
*/
Paga::getMerchantServices();

/** Alternatively, use the helper */    
paga()->getMerchantServices();

/**
* This method returns operation status per transaction.
* @returns array 
*/
Paga::getOperationStatus();

/** Alternatively, use the helper */    
paga()->getOperationStatus();

/**
* This method returns mobile operators on Paga.
* @returns array 
*/
Paga::getMobileOperators();

/** Alternatively, use the helper */    
paga()->getMobileOperators();

/**
* This method allows you to transfer funds from a variety of sources via Paga.
* @returns array 
*/
Paga::moneyTransfer();

/** Alternatively, use the helper */    
paga()->moneyTransfer();

/**
* This method allows you to make bulk money transfer via Paga.
* @returns array 
*/
Paga::moneyTransferBulk();

/** Alternatively, use the helper */    
paga()->moneyTransferBulk();

/**
* This method allows you to purchase airtime via Paga.
* @returns array 
*/
Paga::airtimePurchase();

/** Alternatively, use the helper */    
paga()->airtimePurchase();

/**
* This method allows you to get account balance on Paga.
* @returns array 
*/
Paga::accountBalance();

/** Alternatively, use the helper */    
paga()->accountBalance();

/**
* This method allows you deposit funds into any bank account.
* @returns array 
*/
Paga::depositToBank();

/** Alternatively, use the helper */    
paga()->depositToBank();

/**
* This method allows to validate deposit to bank via Paga.
* @returns array 
*/
Paga::validateDepositToBank();

/** Alternatively, use the helper */    
paga()->validateDepositToBank();

/**
* This method allows to make payments to registered merchants on Paga.
* @returns array 
*/
Paga::merchantPayment();

/** Alternatively, use the helper */    
paga()->merchantPayment();

/**
* This method gets merchant Paga transaction history.
* @returns array 
*/
Paga::transactionHistory();

/** Alternatively, use the helper */    
paga()->transactionHistory();

/**
* This method gets merchant recent Paga transaction history (last 5 records).
* @returns array 
*/
Paga::recentTransactionHistory();

/** Alternatively, use the helper */    
paga()->recentTransactionHistory();

/**
* This method allows aggreagtor organisations create sub organisations on Paga.
* @returns array 
*/
Paga::onBoardMerchant();

/** Alternatively, use the helper */    
paga()->onBoardMerchant();

/**
* This method creates customer on Paga.
* @returns array 
*/
Paga::registerCustomer();

/** Alternatively, use the helper */    
paga()->registerCustomer();

/**
* This method validates customer created on Paga.
* @returns array 
*/
Paga::validateCustomer();

/** Alternatively, use the helper */    
paga()->validateCustomer();

3. 结束语

有关上述服务的更多信息,请访问 Paga 开发者网站

有关更多示例调用,请参阅 SAMPLES

待办事项

  • 添加全面测试
  • 实现高级客户验证方法。

变更日志

请参阅 CHANGELOG 了解最近更改的更多信息。

贡献

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

安全

如果您发现任何与安全相关的问题,请通过电子邮件phalconvee@gmail.com联系,而不是使用问题跟踪器。

我该如何感谢您呢?

请给GitHub仓库点个星。您还可以在Twitter、StackOverflow或HackerNews上分享此存储库的链接。

在Twitter上关注我!

我非常感激 🙏。亨利·乌戈楚库。

致谢

许可协议

MIT许可协议(MIT)。有关更多信息,请参阅许可文件