Stripe API - Next Payment date
$timestamp = "2306060846";
$next_payment_date = date('Y-m-d',$timestamp));
It gives you time in Y-m-d format
You can check the status of the subscription as follows:
customer = Stripe::Customer.retrieve("cus_7G9REJXtaW05QY")
subscription = customer.subscriptions.retrieve("sub_7HFIqkWIDqEhho")
if subscription.status == 'trialing'
next_payment_date = Time.at(subscription.trial_end).strftime("%B %d, %Y")
end
After the trail ends you can check the current_period_end
attribute from the subscription
next_payment_date = Time.at(subscription.current_period_end).strftime("%B %d, %Y")
Moreover, you can use the current_period_end
if you have only one month trial. That would work in all the cases.
PS: For the status check, the word is
trialing
and nottrialling
, if I am not wrong, there is a spelling mistake by Stripe team. :-)
trial_end gives the next_payment_date in timestamp.
You can transfer it into date format using date function in php.
Update: As of mid 2019, for a subscription not currently in trial, you'll find the Unix timestamp for the next billing period in the Subscription
object as current_period_end
.
As far as I know, it is not fully possible. trial_end
(if set) will be the first payment date. current_period_end
will be the next charge attempt, but if there is a decline, the next charges will follow the schedule in the settings (e.g. retry after 1 day, retry after 3 days, cancel). You must track declines and to calculate the next payment date using the rules from the settings.