#openai617_api

1 messages · Page 1 of 1 (latest)

edgy cryptBOT
#

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

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

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.

quaint wren
#

Hi

#

Now I have a requirement, that is, my users are currently in the free period of subscription membership, I hope to complete the deduction when first subscribing, and then modify and postpone the renewal time

#

Hi

#

The current scenario is that my member has a 10-day membership and subscribes to a continuous monthly membership. I hope to complete the deduction when subscribing, and then renew the membership after 10+30 days.

red glade
#

hello! So would the 10 days actually be considered as a "trial"?

quaint wren
#

Yes

red glade
#

ah I see, gimme a while to put together the points of how to achieve what you want

quaint wren
#

好的额

#

OK

#

Do you have a plan?

red glade
#

I think the simplest way to go about this is to create the Subscription, with a 10 day trial, and charge for a one-time amount that is equivalent to the first month. Once payment is successful, add the amount into the Customer Invoice Balance.

You can read up more about the Customer Invoice Balance here : https://docs.stripe.com/billing/customer/balance. You'll want to ensure you go through the following details in this section to understand the limitations : https://docs.stripe.com/billing/customer/balance#details

Subsequently, when the 10 day trial is up, the Subscription will generate an invoice charging for the month, but will automatically apply the customer invoice balance to this invoice.

In case you haven't seen this yet, you can use test clocks to mimic the passing of time : https://stripe.com/docs/billing/testing/test-clocks

test this out to see if it fits your requirements

quaint wren
#

Yes, I know, but the current interface is that I can't deduct the fee immediately after the trial period of 10 days.

#

It seems that the fee will not be deducted until the free period ends.

red glade
#

the fee will be deducted when the subscription is created / first paid for

quaint wren
#

My requirement is that the first subscription must be charged immediately even if it includes a free period, so that the platform membership can be better bound.

#

I tested the code and found that when I passed the billingCycleAnchor parameter, I couldn't deduct the payment immediately through invoice.pay()

red glade
quaint wren
#

Yes I tried

#

When billingCycleAnchor is set, the invoice status is incomplete and payment cannot be deducted through invoice.pay(). Only when the invoice status is active can the pay() method be requested to complete the payment.

#

req_PRuN38BcUAUE5O

red glade
quaint wren
#

I understand that the trial period is used instead of the billingCycleAnchor parameter, right?

red glade
#

correct, you would not pass in billingCycleAnchor

quaint wren
#

But trial_period_days can only be integers

red glade
#

I believe you mentioned you wanted 10 days?

quaint wren
#

The remaining membership days of my original user membership may not be an integer. How can I include the remaining time in the applicable days?

#

The 10 days I mentioned is just an example

#

The real scenario is that my user renews his membership under the specific membership conditions, then the remaining membership can only be included in the subscription usage days to calculate the deduction cycle

#

ok

red glade
#

I'm having some trouble understanding the scenario you described. Can you illustrate this with an example? with the specific dates/days

quaint wren
#

I saw the trial_end field which seems to be suitable for my scenario. Thanks a lot

#

trial_end can satisfy the first deduction, right

#

If the current membership has 9 days and 16 hours left, and I set trial_end to 9 days and 16 hours, can the first deduction be made immediately when subscribing?

red glade
#

no, trial_end does not satisfy the first deduction. The first deduction is based off you including add_invoice_items

quaint wren
#

Which parameter of add_invoice_items can meet my needs?

red glade
#

it's up to you. in short, what you're doing is creating a one-time price. You can either define the price data inline under price_data, or define a Price object that you can just pass the corresponding id into price. If you use price_data, it will always create and archive a new price each time.

quaint wren
#

For example, my current membership expires in 9 days and 18 hours. I want to renew my membership and the fee will be deducted immediately when I subscribe for the first time. Then the membership expiration time should be changed to 39 days and 18 hours. Then the deduction time for the second renewal should be 39 days and 18 hours.

red glade
#

can you try what I suggested first?

quaint wren
red glade
#

just adding on, you also still need to include the recurring price in items

quaint wren
#

When I modified the customization, the first deduction time and the second renewal time were different and had nothing to do with the price.

#

For example, my current membership expires in 9 days and 18 hours. I want to renew my membership and the fee will be deducted immediately when I subscribe for the first time. Then the membership expiration time should be changed to 39 days and 18 hours. Then the deduction time for the second renewal should be 39 days and 18 hours

red glade
#

can you share your request id for the new request you made?

quaint wren
#

For example, today is August 20th, and my app membership expires on August 25th. If I open a membership renewal today and complete the deduction today, then my membership will expire on the first day of 30 days + 5 days, and the second renewal deduction time should be September 25th.

red glade
#

As I mentioned earlier, the suggestion I provided should address your needs. However, unless you test it exactly as I described and pinpoint any issues related to the subscription object created from that method, it's challenging for me to offer further advice.

quaint wren
#

也就是说我必须今天8月20完成扣费,第二次为9月25日,第三次为10月25.....

red glade
#

As an example, the Subscription creation would be like

{
  customer: 'cus_xxx',
  items: [{
    price: 'price_', //recurring price
    quantity:1
  }],
  trial_end:xxx,
  add_invoice_items:[
    {price: 'price_', //one-time price that matches the amount per month }
    quantity:1
    }
  ]
}
quaint wren
#

I read your suggestion but I don't know how these parameters can meet my needs.

#

I need to make sure that my needs are understood.

red glade
#

I think this would be easier to understand if you create the subscription first so that I can walk you through it step by step

#

anyway, the add_invoice_items will create an invoice with that amount for the customer to make payment for upfront

quaint wren
#

That is to say, my requirement must be that the subscription is deducted today, and when the second deduction is made, a delay time needs to be added to the time in the Price, and the third and fourth deductions will remain unchanged.

red glade
quaint wren
#

That means I must complete the deduction today, August 20th, the second time on September 25th, the third time on October 25th, and the fourth time on November 25th....

red glade
#

yes, it can

quaint wren
#

Can you give me an example how add_invoice_items should be passed

#

I don't quite understand the translation of the document.

edgy cryptBOT
opal thicket
quaint wren
#

trial_end cannot complete the first subscription deduction

#

I don't quite understand how to set add_invoice_item because there is no Chinese documentation. The translated one I looked at doesn't seem to meet my needs.

past lantern
#

hi! I'm taking over this thread.

#

trial_end cannot complete the first subscription deduction
what do you mean by this?

quaint wren
#

Your colleague means that the payment cannot be deducted immediately after setting trial_end. Let me test it now.

past lantern
#

I don't quite understand how to set add_invoice_item
can you clarify what you don't understand exactly? did you look at the code we shared above, and the documentation examples?

quaint wren
past lantern
#

we can't write code for you, sorry.

quaint wren
#

<com.stripe.model.StripeError@1798455359 id=> JSON: {
"charge": null,
"code": null,
"decline_code": null,
"doc_url": null,
"message": "Invoice is already paid",
"param": null,
"payment_intent": null,
"payment_method": null,
"payment_method_type": null,
"request_log_url": "https://dashboard.stripe.com/logs/req_2HBSeqK2HloFfb?t\u003d1755678257",
"setup_intent": null,
"source": null,
"type": "invalid_request_error"
}

#

This is the result I got after setting trial_end and deducting the fee immediately

past lantern
#

the error message is pretty clear

quaint wren
#

So this solution cannot meet my needs, understand?

quaint wren
past lantern
#

can you re-explain clearly what you are trying to do?

quaint wren
#

I've said it many times.

#

First, I need to be charged immediately after the first subscription

#

Second, add a delay time when renewing for the second time

past lantern
#

can you share more details? how much do you want to charge immediately? then when it renews, what should be the amount? and what's the delay time your want?

quaint wren
#

The user activated a continuous monthly subscription when the non-continuous monthly subscription has not ended. I want the continuous monthly subscription to be charged immediately, but the second renewal deduction needs to be triggered after the non-continuous monthly subscription expires.

#

The current situation is that my membership is a 10-day membership, and I have subscribed to a continuous monthly membership. I hope to complete the deduction when subscribing, and then renew after 10+30 days.

#

If you are already a member of the platform and then subscribe, the fee will be deducted immediately when you subscribe. If you want to deduct the fee again, you should wait until the 10+30 period expires before deducting the fee.

#

If it's 8:00 AM on August 20th and the user's VIP membership expires at 10:00 AM on August 25th, and they activate a renewal membership, they want the first payment to be deducted upon activation. The renewal period is 30 days, and the second renewal payment will be deducted at 10:00 AM on September 25th. This means there will be a 35-day interval between the second renewal, a 30-day interval between the third renewal, and a 30-day interval between the fourth renewal...

#

Do you understand?

past lantern
#

that's absolutely possilbe. one option to do this:

  • create a subscription with a free 40 day trial (so the new renewal will be in 40 days)
  • use add_invoice_item to make sure the user has to pay immediately when creating the subscription
quaint wren
#

Does that mean that the subscription I paid for initially and the one that comes with a 40-day trial are two subscriptions and I need to subscribe twice?

past lantern
#

I don't understand sorry, why do you have 2 subscriptions?

quaint wren
#

Because I need to satisfy the first subscription deduction

#

You cannot wait until the 40-day trial period ends before charging