Implement custom methods for creating subscriptions.
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);