GithubHelp home page GithubHelp logo

yii2-savano's Introduction

Savano Payment

Savano Payment Gateway Extension For Yii2

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require amirkhh/savano

or add

"amirkhh/savano": "^1.0"

to the require section of your composer.json file.

How to use this extension

For example, imagine that you have a controller called this PaymentController at first you need 2 actions, one of them is for request payment and another is verify payment.

you need to use an storage to save your payments and payments status.

PaymentController.php

..... 

<?php
public function actionRequest()
{
    /* Your Data */
    $pin      = 'Your Pin';
    $callback = 'Your Callback Url';// 'http://www.xxxx.com/payment/verify';

    /* Save Price, OrderId and Authority In Your Storage */
    $price    = 100;
    $orderId  = 1;

    $savano = new Savano;
    $savano->pin = $pin;

    if($request = $savano->request($price, $orderId, $callback)->getResult() === 1)
    {
        // $authority = $savano->getAuthority();
        // You can save your payment request data to the database in here before redirect user to bank

        return $this->redirect($savano->getRedirectUrl());
    }
    else
    {
        // Show Error.
        echo $savano->getErrorMessage();
    }
}

public function actionVerify($au, $order_id)
{
    $pin = 'Your Pin';

    /* Fetch Price, OrderId and Authority in Your Storage */
    $authority = $au;
    $price     = 100;
    $orderId   = $order_id;

    $savano = new Savano;
    $savano->pin = $pin;

    if(($verify = $savano->verify($authority, $price, $orderId)->getResult()) === 1)
    {
        // Payment Successfully
        echo 'Payment Successfully';
    }
    else
    {
	// Show Error
        echo $savano->getErrorMessage();
    }
}

public function beforeAction($action)
{
    if ($action->id == 'verify') {
        $this->enableCsrfValidation = false;
    }

    return parent::beforeAction($action);
}

.....

yii2-savano's People

Contributors

amirkhh avatar

Watchers

 avatar  avatar

Forkers

kpasokhi

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.