Dedicated laravel package for Behpadakht Mellat bank payment service.

Related tags

Laravel mellat-pay
Overview

Iranian Mellat bank full online payment service

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Dedicated laravel package for Behpadakht Mellat bank payment service.

Features

  • Event calls
  • Log on channels
  • builtin rate limiter

Installation

You can install the package via composer:

composer require mjedari/mellat-pay

You can publish and run the migrations and all assets with:

php artisan vendor:publish --tag="mellat-pay"
php artisan migrate

You can publish assets separately:

php artisan vendor:publish --tag="mellat-pay-config"

php artisan vendor:publish --tag="mellat-pay-views"

php artisan vendor:publish --tag="mellat-pay-lang"

This is the contents of the published config file that you should customize it. Its essential to set credentials before any testing. callback is your default callback. You can change package tables name by modifying table. All exceptions an messages will be under your package local language.

return [

    /*
    * Language for errors and messages:
    *
    */
    'local' => 'fa', //en

    /*
    * Description of credentials:
    *
    */
    'credentials' => [
        'username'     => '',
        'password'     => '',
        'terminalId'   => 0000000,
    ],

    /*
    * Gateway's default callback:
    *
    */
    'callback' => '/callback',

    /*
    * Description of table name:
    *
    */
    'table' => 'mellat_transactions',

];

There is one view file that is bank redirector. Optionally, you can publish that and modify for any customizing usage by using

php artisan vendor:publish --tag="mellat-pay"

Simple Usage

There are there main steps. First you should initiate gateway in this way:

// initiate transaction and redirect to bank

$gateway = MellatPay::price(10000)
    ->callback('/payment/callback')
    ->ready();

return $gateway->redirect();

If every this was ok, it redirects you to bank payment page. Then you should define an callback route and wait for bank callback request:

// payment callback route

$gateway = MellatPay::confirm()
    ->then(function ($response) {
        // transaction succeeded and response is transaction full info:
        return $response;
    })->catch(function ($e) {
        // you can get error occurred in transaction verify process:
        return $e->getMessage();
    });

Advance Usage

Transaction payable relation

You can specify transaction to other models with payable method on MellatPay facade. But before that make sure you added payable trait to your related model:

// in your related modal

namespace App\Models;

use Mjedari\MellatPay\Traits\Payable;

class Product extends Model
{
    use payable; // <--- add this trait
    ...
    ...
    ...

}

And in your pay controller

// initiate route

$product = Product::find(1);

$gateway = MellatPay::payable($product)->price(10000)->ready();

Set optional values

there are some options in payment request. you can set description, callback, payer, mobile, payable for each transaction.

Important:

  • If you do not specify callback url, the default one will be used.
  • mobile is useful to send bank and it will be used to autocomplete gateway inputs according to the user's pervious payment card info.
<--- send to bank and store ->callback("https://example.dev/callback/product/245") // <--- callback to etch request ->payer(1) // <--- used as user id ->mobile("989102128582") // <--- used for gateway page autocomplete ->ready(); return $gateway->redirect(); ">
// initiate route full example

    $product = Product::find(245);
    
    $gateway = MellatPay::payable($product)
    ->price(10000) // <--- price in IRR
    ->description("This is a description") // <--- send to bank and store
    ->callback("https://example.dev/callback/product/245") // <--- callback to etch request 
    ->payer(1) // <--- used as user id 
    ->mobile("989102128582") // <--- used for gateway page autocomplete
    ->ready();

    return $gateway->redirect();

Passing custom variables into redirect page

If you want to modify the redirector file, after publishing the view file you can pass any variable into that file by calling this method when redirecting.

// initiate and redirect route

$wallet = Wallet::find(1);
$product = Product::find(1);

$gateway->with($product, $wallet)->redirect();
// or
$gateway->with(['product' => $product, 'wallet' => $wallet]) ...
//or
$gateway->with($product) ...

*Note that transaction info is already accessible by $transaction.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

You might also like...
Backend application using Laravel 9.x REST APIs for games topup from digiflazz.com and payment gateway using xendit.co

TOPUP - Laravel 9.x REST API Documentation is still on progress. For now, you can fork this postman collection Installation Clone this project git clo

A simple Laravel service provider for easily using HTMLPurifier inside Laravel

HTMLPurifier for Laravel 5/6/7/8 A simple Laravel service provider for easily using HTMLPurifier inside Laravel. From their website: HTML Purifier is

MediaDB is a web-based media streaming service written in Laravel and Vue.

MediaDB (API) MediaDB is a web-based media streaming service written in Laravel and Vue. The nginx-vod-module is used for on-the-fly repackaging of MP

Laravel 4.* and 5.* service providers to handle PHP errors, dump variables, execute PHP code remotely in Google Chrome

Laravel 4.* service provider for PHP Console See https://github.com/barbushin/php-console-laravel/releases/tag/1.2.1 Use "php-console/laravel-service-

 Load Laravel service providers based on your application's environment.
Load Laravel service providers based on your application's environment.

Laravel EnvProviders A more finetuned way of managing your service providers in Laravel. This package allows you to configure the environment certain

Contextual Service Providers for Laravel

Laravel Context This simple yet powerful package will help you load different Service Providers depending in which context you are. Contexts can be se

Laravel Lumen service provider for Understand.io

The service provider is deprecated - it does not support error grouping. Laravel Lumen service provider for Understand.io You may also be interested i

Project C2 (Laravel 8.x) - Pemograman Web Service (Semester 5)

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Nusa SMS Laravel Service

A Laravel Service (or library) used to integrate NusaSMS.

Owner
Mahdi Jedari
Laravel Developer
Mahdi Jedari
Razorpay payment gateway integration in laravel with submit form and storing details in payment table.

Integrating razorpay payment gateway in laravel with submit form and storing payment details in payment table. How to settup the project in your local

Mohammed-Thamnees 3 Apr 15, 2021
Learn how to accept a payment from customers around the world with a variety of payment methods.

Accept a payment Learn how to securely accept payments online. This repository includes examples of 2 types of integration types. Prebuilt Checkout pa

Stripe Samples 337 Jan 2, 2023
A laravel service provider for the netsuite-php library service

netsuite-laravel A PHP supplemental package to the ryanwinchester/netsuite-php package to add the NetSuite service client to the service container of

NetsuitePHP 6 Nov 9, 2022
Zarinpal is a laravel package to easily use zarinpal.com payment services in your applications

پکیج اتصال به درگاه پرداخت زرین پال zarinpal.com برای اتصال به درگاه پرداخت اینترنتی زرین پال و استفاده از api های آن می توانید از این پکیج استفاده کن

Rahmat Waisi 4 Jan 26, 2022
A Laravel package to simplify using DPO Payment API in your application.

DPO (Direct Pay Online) Laravel Package The best DPO Laravel package, simple Ever This is the package that will help you add DPO Payment API to your L

Zepson Technologies 5 Nov 17, 2022
A simple package to manage the creation of a structure composed of the service and repository layers in a Laravel application

Chapolim Este projeto tem como objetivo fornecer alguns comandos adicionais à interface de linha de comando do Laravel, o Artisan, para manipular a es

Eliezer Alves 51 Dec 11, 2022
A laravel wrapper for BnpParibas Mercanet payment gateway

Laravel Mercanet A laravel wrapper for BnpParibas Mercanet which provide a lightweight public api to process your online payments from your laravel ap

Mouad ZIANI 29 Nov 27, 2022
SSLCommerz Payment gateway library for Laravel framework

SSLCommerz SSLCommerz Payment gateway library for Laravel framework. Official documentation is here. install composer require sam-asif/sslcommerz Pro

Md. Asif Iqbal 1 Oct 28, 2021
Integrasi Payment Gateway Midtrans dengan Framework Laravel 8

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Martin Mulyo Syahidin 25 Dec 4, 2022
Integerating Laravel with Payment Gateways Paypal, Stripe, Paymob, Paytabs and MyFatoorah

This Repo is for integerating Laravel with some Payment gateways Integeration with For these integerations you need to provide env variables from your

Sherif Nabil 4 Jul 12, 2022