I see there is a lot of information that should be added to the docs. I am very grateful for your questions. I'll try to answer them here and in the future move the answers to the docs. If anything won't be clear after reading them, don't hesitate to ask more. It will definitely help other users.
Daily at 1:00 (right now it's hardcoded)
SubscriptionsOperator::processExpiredSubscriptions() is run. Its job is to automatically change the plans for subscriptions that have expired. It also fires
initbiz.cumulussubscriptions.beforeProcessingExpiredSubscriptions event with
&$expiredSubscriptions parameter before running any logic.
When it comes to orders, they are not created automatically. The plugin gives you three components:
I will describe a typical use case and try to present a solution for your automatic monthly renewing subscriptions.
Typical use case
- Embed the
CreateOrder component on the page that's going to be used by clusters to create new orders.
- Embed the
SubscriptionManage component on your cluster's settings page and select page where the
CreateOrder component is embedded. The
SubscriptionManage component displays information about the current cluster's subscription and allows clusters to show upgrade or prolonging information for their subscription (depending on the current plan).
SubscriptionManage is redirecting to the create-order page (using the
createOrderPage property) with query string built for redirection. The
CreateOrder component uses the parameters from the query string to display offer - "how much will that cost to prolongate or upgrade from your current plan to the one you have selected". After confirmation, the order is created, the order's id is stored in the current session as
initbiz.cumulussubscriptions.order_id and it's redirected to the payment page using the
When it comes to autoconfirmation about the payment status you have to create your own logic in your own
routes.php that will use something like that:
$order = Order::find($orderIdFromService);
Appling the order means upgrading or prolonging the subscription basing on the order details.
Auto-renewing subscription monthly
Bind to the
initbiz.cumulussubscriptions.findExpiringSubscriptions event. It's run daily at 10 am. Right now it's hardcoded. In your handler find subscriptions that expire in, for example, one day:
$expiringSubscriptions = Subscription::active()->endingInExactly(1)->get();
For every subscription create orders:
$order = Order::ofProlongatePlan($expiringSubscription);
And if payment went well you can run:
Order model you have two
additional_data. You can use them to store pretty much everything that concerns the statuses of the payments.
I hope you're satisfied with the support and plugins. Waiting for your feedback!