Giter Site home page Giter Site logo

billing's Introduction

Billing

WARNING!!! If you are already using v1.x version, please stay on it, v2.x may have some backward incompatibilities...

Sell anything for everything...

Latest Stable Version Total Downloads

Billing package for Laravel 5.5+ supporting packages, plans, coupons, addons, payments and subscriptions with multi currencies


Structure:

The structure is the following:

  • Billable - Model that will pay for everything
  • Hostable - Model for which can be purchased everything
  • Package - Model that can be purchased
  • Plan - Model that will sell the Package
  • Reference - Can be any model, that will be purchased with Package
  • Coupon - Discount, which can be applied on Plan purchase

Concept

The concept is the following: To be able to use this package, firstly you need to add Billable trait to your billable model and implement Billable interface (usually it is User model). Hostable models have to implement Hostable interface and use Hostable trait, which will add Purchases relation to model. All packages have to be extended from PackageModel abstract class. That's it!

P. S. Everything is overridable from configuration, provided by package


Installation

composer require ptuchik/billing

After composer installation, just run php artisan migrate as usual, to have the additional tables added to your database and publish configurations by executing:

php artisan vendor:publish --provider="Torann\Currency\CurrencyServiceProvider" --tag=config
php artisan vendor:publish --provider="Ptuchik\Billing\Providers\BillingServiceProvider" --tag=config
php artisan vendor:publish --provider="Ptuchik\CoreUtilities\Providers\CoreUtilitiesServiceProvider" --tag=config

IMPORTANT! Your billable model has to have the following attributes:

  • balance - cast: numeric
  • paymentGateway - cast: string
  • paymentProfiles - cast: array
  • currency - cast: string
  • params - cast: array

and isTester() method, which will indicate if your billable model is tester or customer, to set the correct mode of payment gateway environment. If you don't need testers, you can just create the following method in your billable model:

public function isTester() {
    return false;
}

Usage

To get the plan details, with trial days calculation and summary (all coupons and available balance discounts applied) for current user on current host, just call:

$plan->prepare($hostable); // Will return plan with all calculations applied for logged in user

To purchase the plan, just call:

$plan->purchase($hostable); // It will do the rest automagically

Documentation

Coming soon...


Special thanks to

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.