#openai617_api
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/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.
- openai617_api, 3 hours ago, 32 messages
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.
hello! So would the 10 days actually be considered as a "trial"?
Yes
ah I see, gimme a while to put together the points of how to achieve what you want
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
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.
the fee will be deducted when the subscription is created / first paid for
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()
sorry, i'm confused, did you try what I suggested? Create the Subscription with a 10 day trial, and charge for a one-time amount
if you did, can you share the request id [0] for the subscription creation? it’ll have the prefix req_
[0] https://support.stripe.com/questions/finding-the-id-for-an-api-request
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
you're not using the fields I mentioned. I linked to add_invoice_items (https://docs.stripe.com/api/subscriptions/create#create_subscription-add_invoice_items), but you're passing in a recurring Price to items (https://docs.stripe.com/api/subscriptions/create#create_subscription-items). Also, you didn't define trial_period_days (https://docs.stripe.com/api/subscriptions/create#create_subscription-trial_period_days)
This is the request you made to create a subscription : https://dashboard.stripe.com/logs/req_1P1lylDHorfPk2
I understand that the trial period is used instead of the billingCycleAnchor parameter, right?
correct, you would not pass in billingCycleAnchor
But trial_period_days can only be integers
I believe you mentioned you wanted 10 days?
if you want to specify a specific timestamp, you could also use https://docs.stripe.com/api/subscriptions/create#create_subscription-trial_end
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
I'm having some trouble understanding the scenario you described. Can you illustrate this with an example? with the specific dates/days
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?
no, trial_end does not satisfy the first deduction. The first deduction is based off you including add_invoice_items
Which parameter of add_invoice_items can meet my needs?
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.
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.
can you try what I suggested first?
But this doesn't seem to meet my needs.
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
can you share your request id for the new request you made?
For example, if the number of days I subscribe to Price is 30 days, then I hope to deduct the fee when I first subscribe, and the second deduction must be extended because it includes the remaining days given by the platform.
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.
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.
也就是说我必须今天8月20完成扣费,第二次为9月25日,第三次为10月25.....
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
}
]
}
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.
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
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.
subsequently, you would add that amount to the customer's invoice balance using https://docs.stripe.com/billing/customer/balance#api
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....
Can this demand be met?
yes, it can
Can you give me an example how add_invoice_items should be passed
I don't quite understand the translation of the document.
Can you complete the example on this code?
Oh you are actually almost there! Just take a look at what my colleague sent previously, you would just need to add the trial_end, add_invoice_item fields to your java implementation
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.
hi! I'm taking over this thread.
trial_end cannot complete the first subscription deduction
what do you mean by this?
Your colleague means that the payment cannot be deducted immediately after setting trial_end. Let me test it now.
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?
This code?
we can't write code for you, sorry.
<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"
}
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
This is the result I got after setting trial_end and deducting the fee immediately
this is the request you sent that returned an error: https://dashboard.stripe.com/logs/req_2HBSeqK2HloFfb
the error message is pretty clear
So this solution cannot meet my needs, understand?
Could you take a look at my needs first?
can you re-explain clearly what you are trying to do?
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
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?
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?
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_itemto make sure the user has to pay immediately when creating the subscription
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?
I don't understand sorry, why do you have 2 subscriptions?