#alexesch_code
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/1308714606881017957
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
hello
my first action
$r = $stripe->subscriptionItems->update($main_subscription['items']['data'][0]['id'], [
'quantity' => $main_subscription['items']['data'][0]['quantity'] - 1,
'proration_behavior' => ($subscription_bundle->ref_customer_stripe != $customer_id ? 'none' : 'create_prorations'),
'metadata' => $metadata + ['status' => 'quantity updated'],
]);
my second action
$subscription = $stripe->subscriptions->create([
'customer' => $main_subscription['customer'],
'cancel_at_period_end' => $subscription_bundle->ref_customer_stripe != $customer_id,
'default_payment_method' => $main_subscription['default_payment_method'],
'items' => [
[
'plan' => $main_subscription['items']['data'][0]['plan']['id'],
'quantity' => 1,
],
],
'metadata' => $metadata + ['status' => 'Create a new annual subscription and pay the invoice with the account credits'],
]);
can you check the info by subscription ids?
hello! yep, can you share the Subscription id so that I can take a look?
sure, original subscription (quantity changed: 2 -> 1) https://dashboard.stripe.com/test/subscriptions/sub_1QMiHKJaf89hC41INs0yDsvH
new subscription, for the same customer: https://dashboard.stripe.com/test/subscriptions/sub_1QN7TIJaf89hC41IxCsGLov5
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
๐ taking over for my colleague. Let me catch up.
@lusty ermine I don't see any request that is changing the quantity from 2 to 1 for this subscription
$r = $stripe->subscriptionItems->update($main_subscription['items']['data'][0]['id'], [
'quantity' => $main_subscription['items']['data'][0]['quantity'] - 1,
'proration_behavior' => ($subscription_bundle->ref_customer_stripe != $customer_id ? 'none' : 'create_prorations'),
'metadata' => $metadata + ['status' => 'quantity updated'],
]);
sorry,
req_DpexC6QWyb8oUF
?
sorry I'm investigating this, please hold for a moment
yes this is normal since you're using create_prorations not always_invoice
with create_prorations a pending invoice item will be created and will be pulled to the next subscription's billing cycle
wait i sec, let me explain my case
i'm creating a subscription, with quantity of 2. the price, is 200x2 = 400$
the customer have PAID for this amount
ok
after that, i want to set this subscription quantity to 1, and get 200 credits as proration
ok
after that, i want to create a new subscription, for the same customer, with quantity of 1 and the price = 200
actual behaviour: user is being charged for 200$
expected behaviour: user is not being charged for 200$
how i can do it?
change create_prorations to always_invocie
so, instead of
$r = $stripe->subscriptionItems->update($main_subscription['items']['data'][0]['id'], [
'quantity' => $main_subscription['items']['data'][0]['quantity'] - 1,
'proration_behavior' => ($subscription_bundle->ref_customer_stripe != $customer_id ? 'none' : 'create_prorations'),
'metadata' => $metadata + ['status' => 'quantity updated'],
]);
it will be
$r = $stripe->subscriptionItems->update($main_subscription['items']['data'][0]['id'], [
'quantity' => $main_subscription['items']['data'][0]['quantity'] - 1,
'proration_behavior' => ($subscription_bundle->ref_customer_stripe != $customer_id ? 'none' : 'always_invoice'),
'metadata' => $metadata + ['status' => 'quantity updated'],
]);
right?
yes
ok, let me recheck.