triverla/laravel-opay
Composer 安装命令:
composer require triverla/laravel-opay
包简介
A laravel package for Opay
关键字:
README 文档
README
A Laravel package to seamlessly integrate Opay payment APIs to any new or existing laravel application.
Installation
PHP 7.2+ or HHVM 3.3+, and Composer are required.
To get the latest version of Laravel Opay, simply require it
composer require triverla/laravel-opay
Or add the following line to the require block of your composer.json file.
"triverla/laravel-opay": "1.0.*"
You'll then need to run composer install or composer update to download it and have the autoloader updated.
Once Laravel Opay is installed, you need to register the service provider. Open up config/app.php and add the following to the providers key.
'providers' => [ ... Triverla\LaravelOpay\OpayServiceProvider::class, ... ]
If you use Laravel >= 5.5 you can skip this step and go to
configuration
Triverla\LaravelOpay\OpayServiceProvider::class
Also, register the Facade like so:
'aliases' => [ ... 'Opay' => Triverla\LaravelOPay\Facades\Opay::class, ... ]
Configuration
You can publish the configuration file using this command:
php artisan vendor:publish --provider="Triverla\LaravelOpay\OpayServiceProvider"
A configuration file opay.php with some sensible defaults will be placed in your config directory as displayed below:
<?php return [ 'base_url' => env('OPAY_BASE_URL', 'https://cashierapi.opayweb.com'), 'secret_key' => env('OPAY_SECRET_KEY', ''), 'public_key' => env('OPAY_PUBLIC_KEY', ''), 'merchant_id' => env('OPAY_MERCHANT_ID', '') ];
Usage
Open your .env file and add the following keys. You can get them at (https://merchant.opaycheckout.com/account-details) Under the API keys & Webhook tab:
OPAY_BASE_URL=https://cashierapi.opayweb.com OPAY_SECRET_KEY=XXXXXXXXXX OPAY_PUBLIC_KEY=XXXXXXXXXX OPAY_MERCHANT_ID=XXXXXXXXXX
- import the Opay Facades with the import statement below;
- Also import the FailedRequestException that handles the exceptions thrown from failed requests. This exception returns the corresponding Opay error message and code
... use Triverla\LaravelOpay\Facades\Opay; use Triverla\LaravelOpay\Exceptions\FailedRequestException; ...
Other methods include
use Triverla\LaravelOpay\Facades\Opay; //Bank Endpoints $response = Opay::bank()->countries(); $response = Opay::bank()->banks(); //Wallet $response = Opay::wallet()->initiateTransaction(string $reference, string $userPhone, float $amount, string $userRequestIp, string $productName, string $productDesc, int $expiresAt = 30, string $currency = 'NGN'); $response = Opay::wallet()->authorizeTransaction(string $reference, string $orderNo, string $userPhone, string $pin); $response = Opay::wallet()->sendOTP(string $reference, string $orderNo, string $payMethod); $response = Opay::wallet()->verifyOTP(string $reference, string $orderNo, string $payMethod, string $otp); $response = Opay::wallet()->closeTransaction(string $reference, string $orderNo); $response = Opay::wallet()->initializeRefund(string $reference, string $refundReference, float $refundAmount, string $orderNo, string $currency = 'NGN'); $response = Opay::wallet()->verifyRefundStatus(string $reference, string $refundReference, float $refundAmount, string $refundOrderNo); //Account $response = Opay::account()->createUserAccount(string $phoneNumber, string $email, string $firstName, string $lastName, string $password, string $address, string $otp); $response = Opay::account()->sendOTP(string $phoneNumber); //Inquiry $response = Opay::inquiry()->balance(); $response = Opay::inquiry()->validateOPayUser(string $phoneNumber); $response = Opay::inquiry()->validateOPayMerchant(string $email); $response = Opay::inquiry()->validateBankAccountNumber(string $bankCode, string $bankAccountNumber, string $countryCode = 'NG'); //Transfer $response = Opay::transfer()->opayWallet(WalletTransferPayload $payload); $response = Opay::transfer()->queryWalletTransferStatus(string $reference, string $orderNo); $response = Opay::transfer()->opayWalletBatch(WalletTransferPayloadList $payloadList); $response = Opay::transfer()->bankAccount(BankTransferPayload $payload); $response = Opay::transfer()->queryBankTransferStatus(string $reference, string $orderNo); $response = Opay::transfer()->bankAccountBatch(BankTransferPayloadList $payloadList); //Transactions $response = Opay::transaction()->initializeCardTransaction(string $reference, float $amount, string $firstName, string $lastName, string $customerEmail, string $cardNumber, string $cardDateMonth, string $cardDateYear, string $cardCVC, string $return3dsUrl, string $bankAccountNumber, string $bankCode, string $reason, string $callbackUrl, string $expiresAt, string $billingZip = null, string $billingCity = null, string $billingAddress = null, string $billingState = null, string $billingCountry = null, string $currency = 'NGN', string $country = 'NG'); $response = Opay::transaction()->initializeTokenTransaction(string $reference, float $amount, string $customerPhone, string $customerEmail, string $reason, string $callbackUrl, string $expiresAt, string $token, string $currency = 'NGN', string $country = 'NG'); $response = Opay::transaction()->initializeBankAccountTransaction(string $reference, float $amount, string $customerPhone, string $return3dsUrl, string $bankAccountNumber, string $bankCode, string $reason, string $bvn, string $dobDay, string $dobMonth, string $dobYear, string $currency = 'NGN', string $country = 'NG'); $response = Opay::transaction()->checkTransactionStatus(string $reference, string $orderNo); $response = Opay::transaction()->transactionInputPIN(string $reference, string $orderNo, string $pin); $response = Opay::transaction()->transactionInputOTP(string $reference, string $orderNo, string $otp); $response = Opay::transaction()->transactionInputPhone(string $reference, string $orderNo, string $phone); $response = Opay::transaction()->transactionInputDob(string $reference, string $orderNo, string $dob); $response = Opay::transaction()->initiateBankTransferTransaction(string $reference, string $userPhone, float $amount, string $userRequestIp, string $productName, string $productDesc, int $expiresAt = 30, string $currency = 'NGN'); $response = Opay::transaction()->getBankTransferTransactionStatus(string $reference, string $orderNo); $response = Opay::transaction()->initiateUSSDTransaction(string $reference, string $userPhone, float $amount, string $userRequestIp, string $productName, string $productDesc, int $expiresAt = 30, string $currency = 'NGN'); $response = Opay::transaction()->getUSSDTransactionStatus(string $reference, string $orderNo); //Bills $response = Opay::bills()->bettingProviders(); $response = Opay::bills()->validate(string $serviceType, string $provider, string $customerId); $response = Opay::bills()->bulkBills(BulkBillsListPayload $billsListPayload, string $callbackUrl, string $serviceType); $response = Opay::bills()->bulkStatus(BulkStatusRequest $bulkStatusRequest, string $serviceType);
Testing
composer test
Todo
- Webhook Events
Contributing
Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.
Bugs & Issues
If you notice any bug or issues with this package kindly create and issues here ISSUES
Security
If you discover any security related issues, please email yusufbenaiah@gmail.com.
How can I thank you?
Why not star the github repo and share the link for this repository on Twitter or other social platforms.
Don't forget to follow me on twitter!
Thanks! Benaiah Yusuf
License
The MIT License (MIT). Please see License File for more information.
triverla/laravel-opay 适用场景与选型建议
triverla/laravel-opay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 34 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 07 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「github」 「payments」 「subscription」 「laravel」 「open source」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 triverla/laravel-opay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 triverla/laravel-opay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 triverla/laravel-opay 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Handles basic OAuth/OAuth2 authentication along with classes for common services
MediaWiki extension that allows embedding external content, specified by URL, into your wiki pages
Dealing with payments through the Egyptian payment gateway PayMob
Librería para la gestión sencilla de pagos mediante TPV Redsys y Paypal
Laravel package for the simplification and integration of many of your users most wanted login providers. Installation is a breeze. Never worry about OAuth again.
GitHub Webhook Listener with plugin-based API for creating your own triggerered actions
统计信息
- 总下载量: 34
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-26