#ranger_subscription-update
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/1296518338645852190
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
In your API Request you didn't expand latest_invoice so you get back latest_invoice: 'in_123' as a string, so you can't then try to access its properties
If you aren't familiar with our Expand feature I highly recommend watching https://www.youtube.com/watch?v=m8Vj_CEWyQc and reading https://stripe.com/docs/expand
the error im getting is this;
A new item with Price price_1PseKkKnxJnfLFNQjidOZphH can't be added to this Subscription because an existing Subscription Item si_R32g5slCvB48Cf is already using that Price. If you want to update the existing item (e.g., to adjust the quantity), pass the existing Subscription Item's id in your update request: https://stripe.com/docs/api/subscriptions/update#update_subscription-items-id
I dont understand why its saying the price has been used before in the subscription?
"n your API Request you didn't expand latest_invoice so you get back latest_invoice: 'in_123' as a string" what does this mean? I use this code to create the initial subscription and it works fine.
Okay sorry there are 2 issues. The Expand I said but I didn't notice you already had an error in the API request.
That error means that your Subscription already has that Price id on it, so you can't add the same Price a second time
ranger_subscription-update
hmm, this is a completely different id to the one i used to create the subscription.
Call the Retrieve Susbcription API and look at the response: is your Price id in there?
What you missed is that you did this
- Create Subscription with Price A
- Update Subscription to add Price B so it now has A and B as the request succeeded
- Update Subscription to add Price B -> this fails, you already did this above
- Update Subscription to add Price B -> this fails, you already did this above
ah i suspect it already was added without payment?
i see, if i do an update without going through the payment process does the subscription still get updated?
so when i did the initial test - even though i got internal error the subscription was updated without even going through the payment process?
what i dont get is point 2 didnt go through the paymenet process? I created the initial intent btu as it errored the paymenet element didnt come up.
hmm, im missing something because its been added like you said without being paid for. I suspect its automatically added to subscription charge so the customer doesnt need to go through the paymenet process again?
that's because of the Expand issue
Can you share your code for creating a Subscription
sure
$response = $stripe->subscriptions->create([
'customer' => $customer_id,
'items' => $line_items,
'payment_behavior' => 'default_incomplete',
'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
'expand' => ['latest_invoice.payment_intent']
]);
$status['clientSecret'] = $response->latest_invoice->payment_intent->client_secret;
$status['paymentType'] = "sale";
Hi ๐
I'm stepping in as my colleague needs to go
$line_items = [];
array_push( $line_items, [ "price" => $product_price_id ] );
sure
@crisp hollow see you have used Expand right there
that's what you forgot in the update, that's what I have explained above at the start of the thread, so I'd say to re-read that, it's what caused your issue
(got to run and @vestal coyote is taking over, just wanted to finish driving my point home)
ah i see, so because i didnt use expand the additional item go added?
lol i understand the expand issue, but what i dont understand is do I actually need to get the customer to go through the paymenet process again? or does it just get added automatically?
Give me a sec to catch up
sure
So the customer has an existing subscription and you are adding another line item to it. That should not require the customer going through the payment process again. Have you set the customer's payment method as the default for subscriptions, either on the subscription or on the customer?