Giter VIP home page Giter VIP logo

payir's Introduction

Pay.ir Laravel

Laravel package to connect to Pay.ir Payment Gateway

Installation

composer require saeedvaziry/payir

Publish Configurations

php artisan vendor:publish --provider="SaeedVaziry\Payir\PayirServiceProvider"

Config

Set your api key and redirect url in .env file:

PAYIR_API_KEY=test
PAYIR_REDIRECT=/payir/callback

Usage

Payment Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use SaeedVaziry\Payir\Exceptions\SendException;
use SaeedVaziry\Payir\Exceptions\VerifyException;
use SaeedVaziry\Payir\PayirPG;

class PaymentController extends Controller
{
    public function pay()
    {
        $payir = new PayirPG();
        $payir->amount = 1000; // Required, Amount
        $payir->factorNumber = 'Factor-Number'; // Optional
        $payir->description = 'Some Description'; // Optional
        $payir->mobile = '0912XXXXXXX'; // Optional, If you want to show user's saved card numbers in gateway

        try {
            $payir->send();

            return redirect($payir->paymentUrl);
        } catch (SendException $e) {
            throw $e;
        }
    }

    public function verify(Request $request)
    {
        $payir = new PayirPG();
        $payir->token = $request->token; // Pay.ir returns this token to your redirect url

        try {
            $verify = $payir->verify(); // returns verify result from pay.ir like (transId, cardNumber, ...)

            dd($verify);
        } catch (VerifyException $e) {
            throw $e;
        }
    }
}

Routes

Route::get('/payir/callback', 'PaymentController@verify');

Usage with facade

Config aliases in config/app.php :

'Payir' => SaeedVaziry\Payir\Facades\Payir::class

Send

Payir::send($amount, $redirect = null, $factorNumber = null, $mobile = null, $description = null);

Verify

Payir::verify($token);

Security

If you discover any security related issues, please create an issue or email me ([email protected])

License

This repo is open-sourced software licensed under the MIT license.

payir's People

Contributors

saeedvz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.