From ac363169e768dced005cc73056a49b4b56062ee7 Mon Sep 17 00:00:00 2001 From: Raza Mehdi Date: Wed, 6 Sep 2023 17:13:11 +0500 Subject: [PATCH] Add documentation for Billing Plans API --- docs/source/billing_plans.rst | 200 ++++++++++++++++++++++++++++++++++ docs/source/conf.py | 4 +- requirements.txt | Bin 1204 -> 1260 bytes 3 files changed, 203 insertions(+), 1 deletion(-) diff --git a/docs/source/billing_plans.rst b/docs/source/billing_plans.rst index 751f53b5..66efde64 100644 --- a/docs/source/billing_plans.rst +++ b/docs/source/billing_plans.rst @@ -3,3 +3,203 @@ Billing Plans ============= +This package the following API endpoints for Billing Plans: + +* Create Billing Plan. +* List Billing Plans. +* Show Billing Plan Details. +* Update Billing Plan. +* Activate Billing Plan. +* Deactivate Billing Plan. +* Update Billing Plan Pricing Scheme. + + +Create Billing Plan +------------------- + +This implementation creates a billing plan that defines pricing and billing cycle details for subscriptions by implementing the following API: + +https://developer.paypal.com/docs/api/subscriptions/v1/#plans_create + +.. code-block:: console + + $data = json_decode("{ + "product_id": "PROD-XXCD1234QWER65782", + "name": "Video Streaming Service Plan", + "description": "Video Streaming Service basic plan", + "status": "ACTIVE", + "billing_cycles": [ + { + "frequency": { + "interval_unit": "MONTH", + "interval_count": 1 + }, + "tenure_type": "TRIAL", + "sequence": 1, + "total_cycles": 2, + "pricing_scheme": { + "fixed_price": { + "value": "3", + "currency_code": "USD" + } + } + }, + { + "frequency": { + "interval_unit": "MONTH", + "interval_count": 1 + }, + "tenure_type": "TRIAL", + "sequence": 2, + "total_cycles": 3, + "pricing_scheme": { + "fixed_price": { + "value": "6", + "currency_code": "USD" + } + } + }, + { + "frequency": { + "interval_unit": "MONTH", + "interval_count": 1 + }, + "tenure_type": "REGULAR", + "sequence": 3, + "total_cycles": 12, + "pricing_scheme": { + "fixed_price": { + "value": "10", + "currency_code": "USD" + } + } + } + ], + "payment_preferences": { + "auto_bill_outstanding": true, + "setup_fee": { + "value": "10", + "currency_code": "USD" + }, + "setup_fee_failure_action": "CONTINUE", + "payment_failure_threshold": 3 + }, + "taxes": { + "percentage": "10", + "inclusive": false + } + }", true); + + $plan = $provider->createPlan($data); + + +List Billing Plans +------------------ + +This implementation lists billing plans by implementing the following API: + +https://developer.paypal.com/docs/api/subscriptions/v1/#plans_list + +.. code-block:: console + + $plans = $provider->listPlans(); + +By default, the API returns a paginated response and only includes the first 20 results. However if you pass your own parameters, you can do writing the following: + +.. code-block:: console + + $plans = $provider->listPlans(1, 30); + +In the above snippet, we are returning the plans containing upto 30 items in each paginated response along with count details. + + +Show Billing Plan Details +------------------------- + +This implementation shows details for a billing plan by implementing the following API: + +https://developer.paypal.com/docs/api/subscriptions/v1/#plans_get + +.. code-block:: console + + $plan_id = 'P-7GL4271244454362WXNWU5NQ'; + + $plan = $provider->showPlanDetails($plan_id); + + +Update Billing Plan +------------------- + +This implementation updates details for a billing plan by implementing the following API: + +https://developer.paypal.com/docs/api/subscriptions/v1/#plans_patch + +.. code-block:: console + + $data = json_decode("[ + { + "op": "replace", + "path": "/payment_preferences/payment_failure_threshold", + "value": 7 + } + ]", true); + + $plan_id = 'P-7GL4271244454362WXNWU5NQ'; + + $plan = $provider->updatePlan($plan_id, $data); + + +Activate Billing Plan +--------------------- + +This implementation activates a billing plan by implementing the following API: + +https://developer.paypal.com/docs/api/subscriptions/v1/#plans_activate + +.. code-block:: console + + $plan_id = 'P-7GL4271244454362WXNWU5NQ'; + + $plan = $provider->activatePlan($plan_id); + + +Dectivate Billing Plan +---------------------- + +This implementation deactivates a billing plan by implementing the following API: + +https://developer.paypal.com/docs/api/subscriptions/v1/#plans_deactivate + +.. code-block:: console + + $plan_id = 'P-7GL4271244454362WXNWU5NQ'; + + $plan = $provider->deactivatePlan($plan_id); + + +Update Billing Plan Pricing Scheme +---------------------------------- + +This implementation updates pricing scheme for a billing plan by implementing the following API: + +https://developer.paypal.com/docs/api/subscriptions/v1/#plans_update-pricing-schemes + +.. code-block:: console + + $pricing = json_decode("{ + "pricing_schemes": [ + { + "billing_cycle_sequence": 2, + "pricing_scheme": { + "fixed_price": { + "value": "50", + "currency_code": "USD" + } + } + } + ] + }", true); + + $plan_id = 'P-7GL4271244454362WXNWU5NQ'; + + $plan = $provider->updatePlanPricing($plan_id, $pricing); \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index 6ca4d7af..34ebe21a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,7 +14,9 @@ # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration -extensions = [] +extensions = [ + "sphinx_new_tab_link", +] templates_path = ['_templates'] exclude_patterns = [] diff --git a/requirements.txt b/requirements.txt index ce8125da11c4591c0f2b4df6df3faa8330273351..4da482371d773eb15ad3af2b5dc7bac1bd53e9d0 100644 GIT binary patch delta 52 zcmdnO`G#}D2PSo0hCGH;hH?g7h7yKEh9n@J!;lFS%Vw|zLIVap215|ue4ptmBLG<9 B3