Laravel IMEPay

Laravel IMEPay

Latest Stable Version Total Downloads License
View Package

laravel imepay

Overview: Laravel IMEPay simplifies the integration of IMEPay payment gateway into Laravel applications. With easy installation, configuration, and usage, developers can seamlessly incorporate IMEPay's payment functionality, enhancing the payment experience for users.

Installation: Install the package via Composer:

composer require dipesh79/laravel-imepay

Set environment variables in your .env file:

IMEPAY_MERCHANT_CODE="IMEPAYTEST"
IMEPAY_API_USER="imepaytest"
IMEPAY_API_PASSWORD="imepaytest"
IMEPAY_MODULE="API"
IMEPAY_ENV="Sandbox" #Sandbox or Production
IMEPAY_CALLBACK_URL="http://localhost:8000/imepay/callback"
IMEPAY_CANCEL_URL="http://localhost:8000/imepay/cancel"
IMEPAY_CALLBACK_METHOD="GET" #GET or POST

Publish the vendor file:

php artisan vendor:publish

Usage:

  • Generate a token for payment:
<?php

$token = $imepay->generateToken($amount, $refId);

  • Generate a checkout URL:
<?php

$url = $imepay->generateCheckOutUrl($token, $refId, $amount);

  • Handle callback response:
<?php

$response = $imepay->callbackResponse($request);

  • Confirm a payment:
<?php

$confirmation = $imepay->confirmPayment($refId, $tokenId, $transactionId, $msisdn);

  • Recheck the status of a payment:
<?php

$status = $imepay->recheckPayment($refId, $tokenId);

Methods:

  • generateToken($amount, $refId): Generates a token for the given amount and reference ID.
  • generateCheckoutUrl($token, $refId, $amount): Generates a checkout URL for the given token, reference ID, and amount.
  • callbackResponse($request): Handles the callback response from IMEPay API.
  • confirmPayment($refId, $tokenId, $transactionId, $msisdn): Confirms a payment with the given details.
  • recheckPayment($refId, $tokenId): Rechecks the status of a payment.

Exceptions:

  • ImePayException: Thrown when an error occurs during an IMEPay operation.
  • InvalidKeyException: Thrown when an env key is missing.

License: MIT

Author: @Dipesh79

Support: For support, email dipeshkhanal79[at]gmail[dot]com.

This post is licensed under CC BY 4.0 by the author.