2017 © Pedro Peláez
 

library laravelhubtelmerchantaccount

Hubtel Merchant Account integration for Laravel

image

jowusu837/laravelhubtelmerchantaccount

Hubtel Merchant Account integration for Laravel

  • Friday, February 2, 2018
  • by jowusu837
  • Repository
  • 5 Watchers
  • 4 Stars
  • 349 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 7 Versions
  • 38 % Grown

The README.md

Hubtel Merchant Account integration for Laravel 5

Latest Release on GitHub ![Software License][ico-license] Total Downloads, (*1)

Based on https://developers.hubtel.com/documentations/merchant-account-api, (*2)

About

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

Features

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

Installation

Require the jowusu837/laravelhubtelmerchantaccount package in your composer.json and update your dependencies:, (*4)

$ composer require jowusu837/laravelhubtelmerchantaccount

If you're using Laravel 5.5, this is all there is to do., (*5)

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., (*6)

Add the HubtelMerchantAccount\ServiceProvider to your providers array:, (*7)

Jowusu837\HubtelMerchantAccount\ServiceProvider::class,

And add a new line to the aliases array:, (*8)

'aliases' => [
      ...
      'HubtelMerchantAccount' => Jowusu837\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:, (*9)

namespace App\Http\Controllers;

use Jowusu837\HubtelMerchantAccount\OnlineCheckout\Item;
use HubtelMerchantAccount;
use App\Order;
use Illuminate\Http\Request;

class CheckoutController extends Controller
{

  ...

  public function payOnline(Request $request)
    {
        $order = Order::where('session_id', $request->session()->getId())->latest()->first();

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

        // Initiate online checkout
        $ocRequest = new \Jowusu837\HubtelMerchantAccount\OnlineCheckout\Request();
        $ocRequest->invoice->description = "Invoice description";
        $ocRequest->invoice->total_amount = $order->total;
        $ocRequest->store->name = "My Shop";
        $ocRequest->store->logo_url = asset('/img/logo.png');
        $ocRequest->store->phone = "0243XXXXXX";
        $ocRequest->store->postal_address = "P. O. Box 123456";
        $ocRequest->store->tagline = "Best online shop ever";
        $ocRequest->store->website_url = env('APP_URL');
        $ocRequest->actions->cancel_url = url('/checkout/done');
        $ocRequest->actions->return_url = url('/checkout/done');

        foreach ($order->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 say a controller method:, (*10)

namespace App\Http\Controllers;

use HubtelMerchantAccount;
use Jowusu837\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 = "General payment";
        $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:, (*11)

$ php artisan vendor:publish --provider="Jowusu837\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')
    ],

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

License

Released under the MIT License, see LICENSE., (*12)

The Versions

02/02 2018

dev-master

9999999-dev

Hubtel Merchant Account integration for Laravel

  Sources   Download

MIT

The Requires

 

by Victor J. Owusu

laravel api payment gateway merchant account hubtel

02/02 2018

1.1.2

1.1.2.0

Hubtel Merchant Account integration for Laravel

  Sources   Download

MIT

The Requires

 

by Victor J. Owusu

laravel api payment gateway merchant account hubtel

21/01 2018

1.1.1

1.1.1.0

Hubtel Merchant Account integration for Laravel

  Sources   Download

MIT

The Requires

 

by Victor J. Owusu

laravel api payment gateway merchant account hubtel

24/10 2017

1.1.0

1.1.0.0

Hubtel Merchant Account integration for Laravel

  Sources   Download

MIT

The Requires

 

by Victor J. Owusu

laravel api payment gateway merchant account hubtel

22/10 2017

dev-develop

dev-develop

Hubtel Merchant Account integration for Laravel

  Sources   Download

MIT

The Requires

 

by Victor J. Owusu

laravel api payment gateway merchant account hubtel

24/09 2017

dev-dev

dev-dev

Hubtel Merchant Account integration for Laravel

  Sources   Download

MIT

The Requires

 

by Victor J. Owusu

laravel api payment gateway merchant account hubtel

24/09 2017

1.0.0

1.0.0.0

Hubtel Merchant Account integration for Laravel

  Sources   Download

MIT

The Requires

 

by Victor J. Owusu

laravel api payment gateway merchant account hubtel