#akashpatil7596_api

1 messages · Page 1 of 1 (latest)

tardy iglooBOT
#

👋 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/1232916972702793728

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

lusty mistBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

cunning flame
#

assign me to someone

lusty mistBOT
molten meteor
#

Thanks for waiting!

#

Can you share the example subscription ID (sub_xxx) with the scenario you described?

cunning flame
#

Yes wait

#

here is the subscription id sub_1P9KfESDdRXoIRTqleigscSA

molten meteor
cunning flame
#

Okay but If customer upgrade subscription from $500 to $1000, I want to save $500 as credit balance of that customer

molten meteor
#

What is this $500 credit balance for? Is it for the customer to pay this amount in the next invoice?

cunning flame
#

No just want to save the $500.

molten meteor
cunning flame
#

So let me ask you a question If a customer buy $500 worth subscription today, and upgrade it by $100 worth subscription today, with proration_behaviour : none, Customer has to pay whole $1000, but what about the $500, where does $500 goes?

molten meteor
#

When your system told Stripe proration_behaviour : none, this also asks Stripe not to collect this prorated $500. This $500 will never be collected or go anywhere

#

proration_behaviour: none is to tell Stripe not to collect any proration amount from customer

cunning flame
#

So this $500 will be gone forever?

molten meteor
#

If you wish to collect this $500 from customer, then you shouldn't set proration_behavior to none

#

Can you share what you're trying to achieve here?

#

Setting proration_behavior to none simply tells Stripe that no proration will be collected, so Stripe follow the instruction accordingly that $500 will not be collected

cunning flame
#

I want that If customer switch from $500 to $1000, he/she, have to pay whole $1000 and $500 save into their credit balance

molten meteor
cunning flame
#

How can I manage it manually?

cunning flame
molten meteor
#

Let's step back here. If a subscription is upgraded from $500 to $1000, do you intend to ask the customer to pay $500 prorated amount?

cunning flame
#

No

#

If a customer upgraded from $500 to $1000, I want them to pay $1000

#

But I also want to credit the old $500 in their acoount

#

Could you please tell me a way to achieve this?

#

Hello

#

@molten meteor

molten meteor
#

Thanks for waiting! Discord is busy now and will take time to reply

#

There is not straightforward way to do this. To achieve this, you will:

  1. Update the subscription from $500 to $1000 plan with proration_behavior to none, and add one-time price to add_invoice_item for one-time charge of $1000: https://docs.stripe.com/api/subscriptions/update#update_subscription-add_invoice_items-price - This will allow the subscription to charge a one-time fee of $1000 and also update the $1000 plan instead of using the pre-built proration by Stripe
  2. After the payment of $1000 is successful, then use Customer Balance Transaction API to create a $500 credit balance: https://docs.stripe.com/api/customer_balance_transactions/create
cunning flame
#

Okay If customer upgraded from $500 to $1000 in one day, Then I have to credit $500 in their account, but If that's not the case,
e.g. subscription is $500/month, customer used it for 15 days and then upgrade to $1000 Then I have to credit something around $250, This $250 , Do I have to count it manually, or is there any feature/API from stripe that will do the calculation for me?

molten meteor
cunning flame
#

If a customer buy $500/month and use it for 10 days, How can I get the amount I have to credit for customer? Any API?

molten meteor
cunning flame
#

Um yes, but Do I have to hit this API before I upgraded from $500 to $1000, or after?

molten meteor
#

I'd recommend to do it before with the timestamp that you will be updating the subscription

cunning flame
#

in price I have to pass new priceID of $1000?

molten meteor
#

Yes, new price ID

cunning flame
#

Okay
I bought $500 subscription stimulate the clock for 10 days so the amount now should be 333.33
And then hit this API in the images
And in text file I send you the response, can you tell me where is the amount that are pointing that $500 - 10 days = $300

molten meteor
cunning flame
#

Hey I think I got it

#

I think in here I have to set proration_date , after 10 days, then it will count correctly

molten meteor
#

Yup! subscription_proration_date is the date when you plan to update the subscription

cunning flame
#

Okay and then I got this amount

#

I have to credit this amount to customer, right?

molten meteor
#

If you plan to credit the unused amount, then yes

cunning flame
#

Yes

#

And then upgrade my plan to $1000

#

right?

molten meteor
#

Yes! I'd recommend trying it out in test mode to verify that meets your business requirements

cunning flame
#

Hello

molten meteor
#

How can I help?

cunning flame
#

So I did all that

#

first purchased $500 then $1000, but still the customer has to pay only $500 the remaining amount and not $1000

#

can you look into subscfription ID please?

molten meteor
#

Have you done this?

add one-time price to add_invoice_item for one-time charge of $1000: https://docs.stripe.com/api/subscriptions/update#update_subscription-add_invoice_items-price - This will allow the subscription to charge a one-time fee of $1000 and also update the $1000 plan instead of using the pre-built proration by Stripe

cunning flame
#

sub_1P9MsjSDdRXoIRTqi2L2Jh9q

cunning flame
molten meteor
#

Stripe doesn't support full amount charge. Your system should add one-time charge of $1000 upon upgrading the plan using add_invoice_items

cunning flame
#

add_invoice_items has many parameters, which one I have to use and how?

molten meteor
#

It should be price (price_xxx) of the one-time price of $1000. Or if you should add on demand basis, then price_data can be used

cunning flame
#

You meadn I have to create priceId for $1000 with one-time-paymenyt and then pass into price parameter?

molten meteor
#

Yes

cunning flame
#

Hey , But I have to create a subscription of $1000

molten meteor
cunning flame
#

I don't think you are understanding

#

You said that I have to create priceId for $1000 with one-time payment and no recurring parameter
Then updated the subscription with priceId in add_invoice_items.price
but this won't effect the subscription?

molten meteor
#

Yes - Since you wish to collect the $1000 without proration, the only way is to add one-time price in addition to update the subscription plan, so that this $1000 can be collected. If not, by only updating the subscription will not collect this $1000

tardy iglooBOT
lavish sierra
#

👋 taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

cunning flame
#

Yes Hello

#

The scene is

#

Customer buys subscription $500/month use it for 15 days, the upgrade to $1000/year plan
I return the unused amount which is around $250 to customer's account,

#

Bu then I want that customer Have to pay whole $1000 which is not happening

#

Here's little of my code

lavish sierra
#

you want the billing_cycle to change?

#

or to remain the same?

cunning flame
#

Hello

#

Sorry for late message

cunning flame
lavish sierra
#

what I'm asking basically is do you want to start the new billing cycle right away or stick with the old billing cycle?

#

so let's say the customer subscribed on the 1st of the month and updated the subscription on the 15th, do you want the new cycle to be from the 15th to the next month's 14th?

#

or keep it from the 1st to the last of the month?

cunning flame
#

Yes I want new billing_cycle

#

If customer update to year plan on 15th of the month It should start from 15th to next year's 15th

lavish sierra
#

so you want the customer will have to pay 1000 - 250

#

right?

cunning flame
#

No

#

I want the customer to pay 1000

lavish sierra
#

and you don't want to refund the unused time?

#

so what happens to the 250?

cunning flame
#

I want the 250 to save in customer's credit balance

lavish sierra
#

ok perfect

#

now that I have all of this info I can guide you through the steps

#

you can test these in test mode using test clocks

cunning flame
#

Thanks

lavish sierra
cunning flame
#

No I'm familiar with test clocks

lavish sierra
#

ok perfect

#

so you need to actually know what the proration is first

#

but not apply it because you want to add it to the customer's balance

#

so first thing you need to do, is to preview the invoice with the proration happening

cunning flame
#

Yes and I did that already

#

I got the unused amount with this.stripe.invoices.retrieveUpcoming and credit it to customer with this.stripe.customers.createBalanceTransaction

#

But the issue I'm getting is after done all of this, When I update my subscription to $1000, the payment deducted from customer is $500 and not $1000

#

You got my problem ? @lavish sierra

lavish sierra
#

would you mind sharing the request ID?

cunning flame
#

I don't know how to, I can share the subscription id though

#

sub_1P9MsjSDdRXoIRTqi2L2Jh9q

lavish sierra
#

no worries I can take a look

cunning flame
#

thanku

lavish sierra
cunning flame
#

okay

lavish sierra
#

so you're using proration_behavior none, but you're not changing the billing_cycle_anchor

#

that's why you're just paying half of the month

#

wait

#

I might be saying something wrong

#

give me a second

cunning flame
#

Yes sure

lavish sierra
#

OK I see now what's happening

#

you should apply the customer balance after you finish the subscription update

#

otherwise the amount will be used to cover this invoice

cunning flame
#

you mean first I update the subscription and then credit the unused amount to customer?

tardy iglooBOT
lavish sierra
#

yes

cunning flame
#

Yes that worked actually

#

Can you help me with one more thing please?

trail stream
#

Hi! I'm taking over from my colleague. Please, give me a moment to catch up.

trail stream
cunning flame
#

Yes Hello

#

I have to create price for one time payment and subscription

#

for subscription I do this

  const re = {
        unit_amount: dataObj?.amount,
        currency: dataObj?.currency,
        recurring: { interval: dataObj?.recurring },
        product: dataObj.productId,
      };


      return await this.stripe.prices.create(re);

And for one time payment what should I do?

trail stream
#

Same but without recurring

cunning flame
#
  const re = {
        unit_amount: dataObj?.amount,
        currency: dataObj?.currency,
        product: dataObj.productId,
      };


      return await this.stripe.prices.create(re);

Like this?

trail stream
#

Yes

cunning flame
#

Thanks

trail stream
#

Happy to help.