Skip to content

Implement custom methods for creating subscriptions.

Compare
Choose a tag to compare
@srmklive srmklive released this 05 Dec 14:54
· 123 commits to v3.0 since this release
4454f96

This release implements custom methods to create recurring subscriptions:

  • Daily
  • Weekly
  • Monthly
  • Yearly

Following are the code snippets through which the above can be accomplished:

Create Recurring Daily Subscription

$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE')
            ->addSubscriptionTrialPricing('DAY', 7)
            ->addDailyPlan('Demo Plan', 'Demo Plan', 1.50)
            ->setupSubscription('John Doe', 'john@example.com', '2021-12-10') ;

Create Recurring Weekly Subscription

$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE')
            ->addSubscriptionTrialPricing('DAY', 7)
            ->addWeeklyPlan('Demo Plan', 'Demo Plan', 30)
            ->setupSubscription('John Doe', 'john@example.com', '2021-12-10') ;

Create Recurring Monthly Subscription

$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE')
            ->addSubscriptionTrialPricing('DAY', 7)
            ->addMonthlyPlan('Demo Plan', 'Demo Plan', 100)
            ->setupSubscription('John Doe', 'john@example.com', '2021-12-10') ;

Create Recurring Annual Subscription

$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE')
            ->addSubscriptionTrialPricing('DAY', 7)
            ->addAnnualPlan('Demo Plan', 'Demo Plan', 600)
            ->setupSubscription('John Doe', 'john@example.com', '2021-12-10') ;

Create Subscription by Existing Product & Billing Plan

$response = $this->client->addProductById('PROD-XYAB12ABSB7868434')
    ->addBillingPlanById('P-5ML4271244454362WXNWU5NQ')
    ->setupSubscription('John Doe', 'john@example.com', $start_date);