#akashpatil7596_webhooks
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/1224941238860386344
๐ 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.
- akashpatil7596_api, 15 hours ago, 36 messages
- akashpatil7596_api, 20 hours ago, 35 messages
- akashpatil7596_webhooks, 5 days ago, 15 messages
Do you mean how to call the Refund API?
I mean after catch the webhook, I just calculate the amount of refund and just call the refunds.create API, is that it?
Ah I see
When you update the Subscription from Premium to Basic plan, do you notice there are proration on the generated Invoice?
If you have an example Subscription Id (sub_xxx) happy to take a look
Uhm no I don't think so. Can you share the Subscription Update request (req_xxx) or the Subscription Id sub_xxx
sub_1P17HDIoZDVxPDhemrR25aiS
yesterday I upgrade, today I downgrade
Ah okie I see what happened now
So yesterday you upgrade from a montly $19.99 price to annual $999.99
With proration, so it generates an Invoice https://dashboard.stripe.com/test/invoices/in_1P17QaIoZDVxPDhelV0BudpZ
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Unused on starter = -18.05, Remaining on plus = 999.99
Today you downgrade 999.99 to 19.99 again, with proration it generated https://dashboard.stripe.com/test/invoices/in_1P1LhAIoZDVxPDheuaMsTvHS
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Unused on plus = -999.99 and Remaining on starter = 19.99.
So it gives back 980 to the customer
This is the customer balance and it will offset any of the customer Invoice in the future
It's up to you to refund of not refund it It's totally ok to keep the customer balance as it and not refunding them, because you don't have a specific PI to create the refund from
Okay please listen this,
I'm hitting an API stripe.subscription.update with old item delete which is $999.99/year and add new price $19.99/month,
1). In this case the current month will paid of by from the $999.99 ?
2). I Don't want to paid the current month or next invoices from the credit balance, but I want to give the whole remain credit balance to the customer as refund. How can I do that? I'm using NodeJS for backend.
- Yes as you can observe from the Invoice above
- Okay then you would want to find the Invoice 981.94 (in_1P17QaIoZDVxPDhelV0BudpZ), then find its PI (pi_3P17QaIoZDVxPDhe36B4jqDn) then call Refund on it. This articles explains how to write the finding logic: https://support.stripe.com/questions/refunding-credit-balance-to-customer-after-subscription-downgrade-or-cancellation
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
No I read this article, I just want to say that in refunds.create API which parameters I have to pass?
Like charge_id or payment_intent_id, and pass amount or not?
The amount and the payment_intent. See API Reference: https://docs.stripe.com/api/refunds/create
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
It's explained in the article above ๐
- Using the List Invoices API, pass the Subscription ID in the subscription parameter to view Invoices for that Subscription ID only
- You'll then need to expand the associated charge
No please I do not understand the article, My english is not good. I'm typing this using google translate.
Can you tell me how can I get the payment_intent Id API vise?
Hello
What do you not understand in the article?
First have you tried this step? Using the List Invoices API, pass the Subscription ID in the subscription parameter to view Invoices for that Subscription ID only
Which article are you talking about?
There is nothing for list Invoice or like that
This article
Okay I call await this.stripe.invoices.list({ subscription: subscriptionId });
Got this in response
Can you tell me what can I do next?
Okie, next is modifying this request to expand the charge object
for that which ch_xxx should I pass? in retrive charges API.
I mean on this same Retrive Invoice API, use expand: ['charge']
This?
Yes but on the stripe.invoices.list
But I'm already getting charge id (ch_xxx) in invoice.list API
Yeah but you probably want to check its amount for the logic next:
Okay ,
return await this.stripe.invoices.list({
subscription: subscriptionId,
expand: ['data.charge'],
});
Got this response
Now what can I do further?
This is completely different Subscription, isn't it? Can't do it from sub_1P17HDIoZDVxPDhemrR25aiS?
Here I create whole new , sub_1P1NKlIoZDVxPDheKrFYnDB5
Now what to do further, please guide me
hello @gloomy stream
I mean please follow the articles suggestions there. You would then iterate through the Charges amount and find any Charge which has >0 amount, compare the amount to the credit balance and refund a portion of it, or the whole Charge and move on the next one
Okay leave it, I'm facing another issue here
When Downgrading from $999.99/year to $19.99/month I catch the webhook customer.subscription.updated
And in that I retrive
await this.stripe.subscriptions.retrieve(
subscriptionID,
{
expand: ['latest_invoice.payment_intent'],
},
{
apiKey: publishableKey,
}
)
But in response In latest_invoice object I got charge = null. Why is that, in upgrading this problem don't occur then why in downgrading.
Because this latest_invoice is $0, so it doesn't generate a PaymentIntent
You would want to list older Invoices as well
And find the one with > $0 amount
But I really want the charge for further process,
like this condition that I've applied
if (
stripeCharge.amount_captured > 0 &&
stripeCharge.status == 'succeeded'
){
Yes, so what is the Invoice next in the list and what is its Charge amount?
Sorry, I don't get you
You are calling stripe.subscriptions.retrieve right? You need to call stripe.invoices.list and pass in the Subscription Id instead https://docs.stripe.com/api/invoices/list#list_invoices-subscription
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Like this
I don't get this, This is just giving me bunch of invoices, How that'll help me?
Cause I want the latest Invoice's charge, even If it is zero
I have to get some data from the charge then
like stripeCharge.receipt_url, stripeCharge.payment_method_details.card.last4;
Ok you can close the thread now
But the latest Charge is 0 because it is crediting the Customer. The next one would be non-zero as it has some amount