承接 triverla/laravel-opay 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

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.

Link to Opay documentation

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 triverla/laravel-opay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-26