Giter Site home page Giter Site logo

paymenter's Introduction

Paymenter

  • handle user payment
  • create wallet for user
  • prepare online payment by multi bank portal (by default ZarinPal)

Installation

$ composer require m74asoud/paymenter
$ php artisan vendor:publish --provider="M74asoud\\Paymenter\\PaymenterServiceProvider"
$ php artisan migrate 

usage

Step 1 : add trait PaymenterAble to User model .

use M74asoud\Paymenter\Services\Payment\Contract\PaymenterAble;

class  User  extends  Authenticatable  {
	use PaymenterAble;
}

PaymenterAble includes below methods:

use M74asoud\Paymenter\Models\Bill;
use M74asoud\Paymenter\ObjectValue\Money;
use M74asoud\Paymenter\Services\Payment\PaymenterTDO;
use M74asoud\Paymenter\Services\Payment\Types\Contract\PaymenterTypeInterface;
  • $user->balance() : Money

    balance method return the latest inventory of the user's wallet

  • $user->hasMoney(Money $money): bool

    does user hasMoney in wallet

  • $user->getPaymenterTypes(): array

    return existing payment method example : wallet - online , ...

  • $user->getOnlinePaymentPortals(): array

    return all active bank portals

  • $user->pay( PaymenterTDO $paymenterTDO, PaymenterTypeInterface $paymenter_type = null ): bill

  • $user->recharge( PaymenterTDO $paymenterTDO, PaymenterTypeInterface $paymenter_type = null ): bill

Step 2 : create a custom class any where and implement PaymenterControllerInterface like below

namespace  App\Http\Controllers;
use M74asoud\Paymenter\Services\Payment\Contract\PaymenterControllerInterface;

class  PaymentVerify  implements  PaymenterControllerInterface
{

	public  function  verifyHandler(Bill  $bill)
	{
		// do something you like
	}

}

Step 3 : in your project AppServiceProvider Bind PaymenterControllerInterface to your Custom Class

public  function  register()
{
	$this->app->bind(PaymenterControllerInterface::class,CustomClass::class);
}
$bill->status :
const  Status  =  [
                 'pending'  	 	 =>  0,
                 'watingPay'  	 =>  1,
                 'paid'  	 	 =>  2,
                 'noEnoughMoney'  =>  3,
                 'error'  		 =>  4
 			];


* if use online payment and $bill->status === 1 (watingPay)
you must redirect user to bank portal with link : 
$bill->paymentTransaction->requestPay() , then verify user payment in your custom class than created.


* when you try to pay or recahrge you must pass an object of PaymenterTDO .
PaymenterTDO argumans  :
 - Money  $amount,
 - string  $description,
 - int  $type ### this arguman Special for you , you can pass any integer and then verify $bill in your custom handler by it;

paymenter's People

Contributors

w74anheda avatar yousofss 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.