Reputation: 25
I am using "laravel/cashier-braintree": "~2.0"
package to manage subscriptions in my Laravel 5.5.40
application.
So far i have created a plan to and created subscriptions to the plans via multiple users. I just cant find a way to get the plan expiry date for a user.
Based on this laracast discussion, the ends_at column in subscriptions
table stays null by default until a user cancels the subscription.
I did try the Customer::find($braintree_id)
method and got a huge customer detail object with a subscriptions
object as below:
"subscriptions": [
{
"addOns": [],
"balance": "0.00",
"billingDayOfMonth": 20,
"billingPeriodEndDate": {
"date": "2018-09-19 00:00:00.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"billingPeriodStartDate": {
"date": "2018-06-20 00:00:00.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"createdAt": {
"date": "2018-06-20 10:06:42.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"updatedAt": {
"date": "2018-06-21 05:56:43.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"currentBillingCycle": 1,
"daysPastDue": null,
"discounts": [],
"failureCount": 0,
"firstBillingDate": {
"date": "2018-06-20 00:00:00.000000",
"timezone_type": 3,
"timezone": "UTC"
},
So is there any better way to get the plan subscription expiry date?
Upvotes: 1
Views: 274
Reputation: 701
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
Right now the subscription response object does not contain an attribute returned regarding the end date for a subscription. You can subtract the currentBillingCycle
from the numberOfBillingCycles
to find out when the subscription is set to end. I recommend first checking to see whether neverExpires
returns as true
to see if there is an end date.
For example, if the numberOfBillingCycles
has a value of 12
and the currentBillingCycle
is 4
, the number of billing cycles remaining is 8
.
Upvotes: 2