#erik_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1235915149936820306
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi! do you have the request ID req_xxx from that error message?
Where can I see it?
it's in the message itself
req_7zJj0BgGtvwVHf
I think you just need to omit the billing_cycle_anchor parameter from that request and pass a trial_end that equates to the current end date plus 1 month, as noted here: https://docs.stripe.com/billing/subscriptions/billing-cycle#add-a-trial-to-change-the-billing-cycle
Then on that trial_end timestamp the sub will cycle into a new period and customer will be charged again
trial end was successfull but it scheduled $3.86 on the date I have rescheduled to the subscription and rest 116.14 they charged immediately again
An example sub_xxx/in_xxx would be helpful
Here you see the description May 3 2024 to May 3 2025 and I need to make it end date like August 3 2025 only.
The ID, please. Screenshots aren't really helpful. We can look at the objects directly
You've just send me a very long string. Can you please just paste the in_xxx ID
The only way to do that with a yearly price like you had would be to set the anchor to Aug 3 2024 after the trial_end date: https://docs.stripe.com/billing/subscriptions/trials#combine-trial-anchor
But the billing_cycle_anchor has to be after trial_end
is it going to create another subscription or it will update the upcoming invoice date?
So imagine this scenario:
- You give them a May for free for the missed content article and set
trial_endto reflect that - You pass in
billing_cycle_anchorfor Aug 3rd (or whenever). At the end of the trial, we'll create a prorated invoice for the time between the end of the trial and Aug 3rd - On Aug 3rd they'll new yearly invoice for $120 for the period up until Aug 2025
It'll create a new $0 amount invoice now to reflect the trial period for the 'grace' period you want to give them
OK just for my satisfaction I am repeating what exactly I am looking for;
I am a shop owner where I sell content subscription. I have 120 USD/ year charges where I used to send every months a new content let's for some reason I skipped one month so now for all my subscriber who has only recieved 11 content only their cycle should be updated for next one more month without any single penny extra charges and after 1 month they will be charged again 120 USD
This should do exactly what you need
OK awesome
You're basically adding a 'free' period to the end of the current billing period
$stripe->subscriptions->create([
'customer' => '{{CUSTOMER_ID}}',
'items' => [['price' => '{{PRICE_ID}}']],
'trial_end' => 1610403705,
'billing_cycle_anchor' => 1611008505,
Please explain these parameters, what should I add into these
I have customer ID and price should be 120?
what would be trial end and biicling cycle anchor?
Why are you creating a new Subscription?
You have suggested to use this code?No? I am sorry if something I got wrong
No, you're updating the existing subscription(s) as per your requirements to give them a 'free' month
It's right here: https://docs.stripe.com/billing/subscriptions/billing-cycle#add-a-trial-to-change-the-billing-cycle
$stripe = new \Stripe\StripeClient('sk_test_51NVfi7ASq4Fhb5zzdCGGSQHQmze9Tv2dtRXpRERPbZV9TWyMzIBUIgfRiAMsd0D63LxeBC5A5UQEwCKMcRZuOA5q000XsruSsu');
$stripe->subscriptions->update(
'sub_49ty4767H20z6a',
[
'trial_end' => 1611008505,
'proration_behavior' => 'none',
]
);
trail end will contain when I am updating the subscription date time+1 month addition right?
Hey! Taking over for my colleague.
trail end will contain when I am updating the subscription date time+1 month addition right?
Yes, I inivte you to try it.
Sure, Please stay there
it did the work however it worked for wrong subscription. I have two subscription for the same user one is monthly and one is yearly it went for monthly instead os yearly
There?
yes
Try to update the other one with its Id
I have two subscription for the same customer ID one is monthly and one is yearly, changes yearly, Changes yearly, Changes were made in monthly where it was supposed to be made in yearly?
Hello sir?
Sorry I'm not understanding your last follow up question.
one is yearly, changes yearly, Changes yearly, Changes were made in monthly where it was supposed to be made in yearly?
Can you share the related subscirption id and what you want to achieve exactly ?
You can see the subscriptions here for the same user, I am fetching user subscriptions data using this code $stripe_data = $stripe->invoices->upcoming(['customer' => $customer_id]);
it is only returing subscription id of monthly subscription not for yearly that's why it is updating monthly subscription data instead of yearly
And did you made the update request on the other subscription ?
This update is for one Subscipriton, and for the other one what request/API call you made in order to make the change ?
I also want to make change in yearly subscription only
$new_renewal_date = strtotime('+3 months', $stripe_data->period_end);
$stripe->subscriptions->update(
$stripe_data->subscription,
[ 'trial_end' => $new_renewal_date,'proration_behavior' => 'none',]
);
Can you share the requestId of the API call for updating the yearly subscription ?
https://support.stripe.com/questions/finding-the-id-for-an-api-request
I hope you are not getting me. This is the entire code from fetching subscriptions to adding the trial:
$stripe_data = $stripe->invoices->upcoming(['customer' => $customer_id]);
echo "<pre>"; print_r($stripe_data);die;
$new_renewal_date = strtotime('+3 months', $stripe_data->period_end);
$stripe->subscriptions->update(
$stripe_data->subscription,
[ 'trial_end' => $new_renewal_date,'proration_behavior' => 'none',]
);
I have nothing else other than this. It is just updating monthly subscription instead of yearly. I did not make any request to update yearly subscription other than this
So that's expected if the yearly Subscription isn't updated
If you want to update the yearly Subscirption you need to make an update request on it, same to what you did with the Monthly Subscription
Can you please add your collegue back? How can I hit the request when I am not able to get the subscription ID in my code? I sent you my code and it is only returing the monthly subscription ID. Its simple
I need to know from you how to get yearly subscription ID using the code I sent above
I need to know from you how to get yearly subscription ID using the code I sent above
Ok now it's clear, thanks for the clarification. You can list all the Subscriptions of the customer using this API:
https://docs.stripe.com/api/subscriptions/list
You need to filter by Customer Id:
https://docs.stripe.com/api/subscriptions/list#list_subscriptions-customer
You guys are amazing. Thanks. I have resolved it now
Happy to help!