Giter Site home page Giter Site logo

commerce_recurring's Introduction

Provides recurring billing for Drupal Commerce, powered by Advanced queue.

The successor to Commerce Recurring and Commerce License Billing for D7.

Features:

  • Configurable billing intervals (charge every N days/weeks/months/years).
  • Fixed and rolling interval types (charge on the 1st of the month VS 1 month from the subscription date)
  • Prepaid and postpaid payment types (charge at the beginning or at the end of the billing cycle).
  • Free trial of any interval (14 days followed by a regular monthly subscription, etc)
  • Prorating (adjusting the charged price based on the duration of its usage)
  • Usage tracking (track bandwidth and charge per GB, etc).

Use cases

  1. Recurring membership (via commerce_license)

Prepaid billing for a license (usually of type "role").

  1. Recurring SaaS subscription

Postpaid billing, with optional usage, for a license.

  1. Donations

Prepaid billing for a product variation (no license). Customers can usually select between multiple billing schedules (monthly/yearly, etc).

Future use cases: Physical products (Dollar Shave Club, etc)

General idea

Each product variation represents a subscription plan and can be used to start a subscription. A product can have multiple variations, representing multiple plans the customer can choose from. For example, Basic and Premium memberships.

Each variation can have one or more billing schedules, which determine how the subscription will be billed (interval, interval type, payment type, free trial settings, etc).

On the add to cart form, the customer chooses a plan and a billing schedule (hidden if there's only 1 possible option), which are stored on the order item in the purchased_entity and billing_schedule fields. If the billing schedule dictates "postpayment" as the payment type, the initial unit price of the order item is 0.The customer provides their billing information and completes checkout. When the order is placed, a subscription is open for each order item with a specified billing_schedule. As soon as the subscription is activated, the billing schedule generates a billing cycle, and opens a recurring order for that billing cycle.

Once the billing cycle expires ($order->billing_cycle->end_date < time()), the module's hook_cron() implementation queues the order for closing and renewal. The queue worker then processes each order, collecting payment (via $subscription->payment_method), and opening the next recurring order.

Concepts

Plan

The purchased entity (product variation, product bundle, etc). References N billing schedules and 1 subscription type.

Billing schedule

Config entity + plugin (interval with number/unit, interval type, trial interval, payment type).

Billing cycle

Generated by the billing schedule plugin. A value object with the following properties: index, start_date, end_date. Index '1' means this is the first billing cycle. Can be used by promotions to discount only the first N orders, or by the subscription itself to stop recurring after N cycles.

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.