GithubHelp home page GithubHelp logo

fmmajd / iran-payment Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dena-a/iran-payment

0.0 1.0 0.0 375 KB

a Laravel package to handle Internet Payment Gateways for Iran Banking System

License: MIT License

PHP 70.24% HTML 29.76%

iran-payment's Introduction

IranPayment

a Laravel package to handle Internet Payment Gateways for Iran Banking System

Installation

You can install the package via composer:

$ composer require dena-a/iran-payment

This service provider must be installed.

// config/app.php
'providers' => [
    ...
    Dena\IranPayment\IranPaymentServiceProvider::class
];

Add aliases:

// config/app.php
'aliases' => [
    ...
    'IranPayment' => Dena\IranPayment\IranPayment::class,
];

Publish the config-file and migration with:

php artisan vendor:publish --provider="Dena\IranPayment\IranPaymentServiceProvider"

After the migration has been published you can create the transactions-tables by running the migrations:

php artisan migrate

Usage

New Payment:

//default gateway
$payment = new IranPayment();
// OR one of ['zarinpal', 'saman', 'payir']
$payment = new IranPayment('zarinpal');
// OR test gateway (Only works on debug mode)
$payment = new IranPayment('test');

$payment->build()
        ->setUserId($user->id)
        ->setAmount($data['amount'])
        ->setCallbackUrl(route('bank.callback'))
        ->ready();

return $payment->redirectView();

Verify Payment:

$payment = new IranPayment();
$payment->build()->verify($transaction);
$trackingCode = $payment->getTrackingCode();
$statusText = $payment->getTransactionStatusText();

Extends

use Dena\IranPayment\Providers\BaseProvider;
use Dena\IranPayment\Providers\GatewayInterface;

class NewGateway extends BaseProvider implements GatewayInterface {
    
    public function getName() {
        return 'new-gateway';
    }
    
    public function payRequest() {
        $code = rand(1, 10000);
        $this->setReferenceNumber($code);
        $this->transactionPending([
            'reference_number'	=> intval($code)
        ]);
    }
    
    public function verifyRequest() {
        $this->transactionVerifyPending();
        $code = rand(1, 10000);
        $this->setTrackingCode($code);
		$this->transactionSucceed(['tracking_code' => $code]);
    }
    
    public function redirectView() {
        return view('welcome')->with([
            'transaction' => $this->getTransaction()
        ]);
    }
    
    public function payBack() {
    }
}

$payment = new IranPayment();
$payment->extends(NewGateway::class);

License

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

iran-payment's People

Contributors

dena-a avatar yeknava avatar fmmajd avatar

Watchers

James Cloos 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.