承接 nanatty32/laravelhubtelmerchantaccountcedibet 相关项目开发

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

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

nanatty32/laravelhubtelmerchantaccountcedibet

Composer 安装命令:

composer require nanatty32/laravelhubtelmerchantaccountcedibet

包简介

Laravel Hubtel Merchant Account integration (Pure Laravel CediBet)

README 文档

README

ico-version

Based on https://developers.hubtel.com/documentations/merchant-account-api

About

The laravel-hubtel-merchant-account-cedibet package allows you to accept and process payments using Hubtel Merchant Account API directly in your Laravel application.

Features

  • Receive mobile money
  • Send mobile money
  • Check status of transaction
  • Online checkout

Installation

Require the nanatty32/laravelhubtelmerchantaccountcedibet package in your composer.json and update your dependencies:

$ composer require nanatty32/laravelhubtelmerchantaccountcedibet

If you're using Laravel 5.5, this is all there is to do.

Should you still be on older versions of Laravel, the final steps for you are to add the service provider of the package and alias the package. To do this open your config/app.php file.

Add the HubtelMerchantAccount\ServiceProvider to your providers array:

Nanatty32\HubtelMerchantAccount\ServiceProvider::class,

And add a new line to the aliases array:

'aliases' => [
      ...
      'HubtelMerchantAccount' => Nanatty32\HubtelMerchantAccount\HubtelMerchantAccountFacade::class,
      ...
 ]

Using Online Checkout feature

Let's say you are using this feature from a controller method, you can do it like so:

namespace App\Http\Controllers;

use Nanatty32\HubtelMerchantAccount\OnlineCheckout\Item;
use HubtelMerchantAccount;
use App\Stake;
use Illuminate\Http\Request;

class CheckoutController extends Controller
{
  
  ...
  
  public function payOnline(Request $request)
    {
        $stake = Stake::where('session_id', $request->session()->getId())->latest()->first();

        if (!$stake) {
            abort(404, 'Invalid stake!');
        }

        // Initiate online checkout
        $ocRequest = new \Nanatty32\HubtelMerchantAccount\OnlineCheckout\Request();
        $ocRequest->invoice->description = "Invoice description";
        $ocRequest->invoice->total_amount = $stake->total;
        $ocRequest->business->name = "CediBet";
        $ocRequest->business->logo_url = asset('/img/logo.png');// Can be changed by developers 
        $ocRequest->business->phone = "0243XXXXXX";
        $ocRequest->business->postal_address = "P. O. Box ******";
        $ocRequest->business->tagline = "Best online Betting Company In Ghana";
        $ocRequest->business->website_url = env('APP_URL');
        $ocRequest->actions->cancel_url = url('/checkout/done');
        $ocRequest->actions->return_url = url('/checkout/done');

        foreach ($stake->items as $item) {

            $invoiceItem = new Item();
            $invoiceItem->name = $item->product_name;
            $invoiceItem->description = "";
            $invoiceItem->quantity = $item->quantity;
            $invoiceItem->unit_price = $item->price;
            $invoiceItem->total_price = $item->price * $item->quantity;

            $ocRequest->invoice->addItem($invoiceItem);
        }
       
        HubtelMerchantAccount::onlineCheckout($ocRequest);
    }

Receive Mobile Money

Here is how you request mobile money payment from the controller method:

namespace App\Http\Controllers;

use HubtelMerchantAccount;
use Nanatty32\HubtelMerchantAccount\MobileMoney\Receive\Request as ReceiveMobileMoneyRequest;

class CheckoutController extends Controller
{
  
  ...
  
  public function payOnline(Request $request)
    {
        $request = new ReceiveMobileMoneyRequest();
        $request->Amount = $this->transaction->amount;
        $request->Channel = $this->transaction->channel;
        $request->CustomerMsisdn = $this->transaction->mobile_wallet_number;
        $request->CustomerName = "N/A";
        $request->Description = "Bet Amount";
        $request->PrimaryCallbackURL = "https://my-application.com/handle" . $this->transaction->id;
        $request->SecondaryCallbackURL = "https://my-application.com/handle/" . $this->transaction->id;
        $response = HubtelMerchantAccount::receiveMobileMoney($request);
    }

Configuration

The defaults are set in config/hubtelmerchantaccount.php. Copy this file to your own config directory to modify the values. You can publish the config using this command:

$ php artisan vendor:publish --provider="Nanatty32\HubtelMerchantAccount\ServiceProvider"
return [

    /**
     * Merchant account number
     */
    "account_number" => env('HUBTEL_MERCHANT_ACCOUNT_NUMBER'),

    /**
     * Login credentials for hubtel api
     *
     */
    "api_key" => [
        "client_id" => env('HUBTEL_MERCHANT_ACCOUNT_CLIENT_ID'),
        "client_secret" => env('HUBTEL_MERCHANT_ACCOUNT_CLIENT_SECRET')
    ],

    /**
     * business details
     */
    "business" => [
        "name" => env('APP_NAME')
    ]
];

License

Released under the MIT License, see LICENSE.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固