#erik_api

1 messages ยท Page 1 of 1 (latest)

uncut thunderBOT
#

๐Ÿ‘‹ 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.

hardy stoneBOT
silent stratus
#

hi! do you have the request ID req_xxx from that error message?

plush pollen
#

Where can I see it?

silent stratus
#

it's in the message itself

plush pollen
#

req_7zJj0BgGtvwVHf

halcyon flax
#

Then on that trial_end timestamp the sub will cycle into a new period and customer will be charged again

plush pollen
#

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

halcyon flax
#

An example sub_xxx/in_xxx would be helpful

plush pollen
#

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.

halcyon flax
#

The ID, please. Screenshots aren't really helpful. We can look at the objects directly

plush pollen
#

Sure

#

Here you can see the info

halcyon flax
#

You've just send me a very long string. Can you please just paste the in_xxx ID

plush pollen
#

in_1PCFODASq4Fhb5zzTf9T1WDT

#

subscription id; sub_1PBflSASq4Fhb5zzOl3HSEZc

halcyon flax
#

But the billing_cycle_anchor has to be after trial_end

plush pollen
#

is it going to create another subscription or it will update the upcoming invoice date?

halcyon flax
#

So imagine this scenario:

  • You give them a May for free for the missed content article and set trial_end to reflect that
  • You pass in billing_cycle_anchor for 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
halcyon flax
plush pollen
#

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

halcyon flax
plush pollen
#

OK awesome

halcyon flax
#

You're basically adding a 'free' period to the end of the current billing period

plush pollen
#

$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?

halcyon flax
#

Why are you creating a new Subscription?

plush pollen
#

You have suggested to use this code?No? I am sorry if something I got wrong

halcyon flax
#

No, you're updating the existing subscription(s) as per your requirements to give them a 'free' month

plush pollen
#

yes and where can I see the code for the same?

#

I mean how to update?

halcyon flax
plush pollen
#

$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?

ripe grail
#

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.

plush pollen
#

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?

ripe grail
#

Yes

#

You are updating the wrong subscription, what do you mean exactly by this ?

plush pollen
#

yes

ripe grail
#

Try to update the other one with its Id

plush pollen
#

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?

ripe grail
#

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 ?

plush pollen
#

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

ripe grail
#

And did you made the update request on the other subscription ?

ripe grail
plush pollen
#

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',]
);

ripe grail
plush pollen
#

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

ripe grail
#

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

plush pollen
#

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

ripe grail
#

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

plush pollen
#

You guys are amazing. Thanks. I have resolved it now

ripe grail
#

Happy to help!