#kun_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/1278560324525621288
đ 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.
- kun_api, 17 hours ago, 56 messages
- kun_webhooks, 21 hours ago, 20 messages
- kun_setupintents-savedpms-defaultpm, 2 days ago, 65 messages
Hi there, you don't need to cancel the existing subscription, you can just update it with the new price. Details here: https://docs.stripe.com/billing/subscriptions/upgrade-downgrade
yes this is what I am doing and implemented it successfully
but I have a concern
as for this process 3DS is required.
which I am sending it to the customer through email
my first concern
1 once it is approved by user and subscription is paid and active for every next recurring payment do it required 3DS again and then again sending email
2 Is there another way for 3DS instead of sending the hosted URL
3 when I click on the hosted url my card fields are not populated as I already attached the paymente method when cutomer subscribe to my product to 1st time
const sub = await this.stripe.subscriptions.update(
latestSubscription.id, // Your subscription ID
{
items: [
{
id: latestSubscription.items.data[0].id, // Your subscription item ID
price: 'price_1PZL8KFrwl37tCGiAOd8u8Pd', // Your new price ID
},
],
expand: ['latest_invoice.payment_intent'],
},
);
this is the code snippet I am using and Tested successfully
- 3DS request is determiend by the card issuer and your Radar rule, there's no way completely avoid it and your integration should always handle it
- You can also handle 3DS by yourself . You can navigate your customer to your website where you can call
stripe.confirmCardPaymentto initiate the 3DS flow - Did you attach the payment method to the subscription?
for your 3rd point
You can see my code snippet please
What's the subscription ID?
for your 1 pont:
once I did 3DS for the first time my subscription charge recurring automatocally.
but I am think it as same that once the user upgrade the subscription with new product priice_id
and after completion of 3DS the next recurring charge automatically
latestSubscription.id this is my subscription id
latestSubscription.items.data[0].id this is my subscription item id
??
Can you print the latestSubscription.id ?
Stripe will send an email to you customer when a payment requries confirmation
However we don't send such emails in test mode.
ok I have a question here
will it possible with this.stripe.subscriptions.update
I can attach the payment_method
and get the client secret
and on forntend I using confirmCardPayment to apply 3DS
???
??
????
you there
is anyone there
const sub = await this.stripe.subscriptions.update(
latestSubscription.id, // Your subscription ID
{
items: [
{
id: latestSubscription.items.data[0].id, // Your subscription item ID
price: 'price_1PZL8KFrwl37tCGiAOd8u8Pd', // Your new price ID
},
],
default_payment_method: paymentMethodId,
expand: ['latest_invoice.payment_intent'],
},
);
I have updated the code
will this work by sending the client_secret to frontend
Yes, client_secret is in the expanded payment_intent object
alright let me summarize it and lease confirm
1 update the subscription with new product price_id
2 attach with old payment_method (which was created first time for subscription)
3 Add this key while updating expand: ['latest_invoice.payment_intent'],
On frontend
1 send the client secret
2 use confirmCardPayment or use confirmCardSetup
3 I will using
const { error, paymentIntent } = await stripe.confirmCardPayment(clientSecret, {
payment_method: 'pm_new_payment_method_id', // Replace with the saved payment method ID
});
on frontend
Please confirm it
You don't need to specify payment_method in confirmCardPayment, just call confirmCardPayment with clientSecret will do. You can test this out in test mode
in confirmCardPayment
I dont need card details or paymentMethod right?
Yes you are right, the paymentIntent should already have the payment_method attached to it.
And you only need to call confirmCardPayment if the payment_intent is in requires_action state.
so here I should call confirmCardPayment right?
but confirmCardPayment takes 2 arguments
1 client_secret
2 card elements or payment methodId
https://docs.stripe.com/js/payment_intents/confirm_card_payment only clientSecret is mandatory
Happy to help!
How can I help?
Hi
I am trying to upgrade subscription
well I just created two new products
one with 0.10 usd per day
other is 2 usd per day
when I use their price_id I get payment_intent null
but those products which are old and I use their price_id i get my payment_intent populated with data
why?
even my new products are active
when I use their price_id I get payment_intent null
Could you share request ID (req_xxx) which you face payment intent as null when attempting to upgrade the subscription?
I dont know how to get req id
i can share subscri[ption id?
??
or can I share the response when I update my subscription
are you there?
Discord is a public channel and can be busy some time. It will take time to reply
Could you share your subscription ID (sub_xxx), so that I can take a look?
In https://dashboard.stripe.com/logs/req_KKEPo2h0SsZbv2 when the subscription item is updated, the prorated invoice created is $0: https://dashboard.stripe.com/invoices/in_1Pt1sHFrwl37tCGiY1NnjRIy
When an invoice is $0, no payment intent will be available
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.
what should i do?
You don't need to do anything since payment is not required
// Get the latest subscription for the customer
const { data: subscriptions } = await this.stripe.subscriptions.list({
customer: customerId,
});
const latestSubscription: any = subscriptions.reduce((latest, current) =>
current.created > latest.created ? current : latest,
);
// Update the subscription to use the new payment method
const updatedSubscription: any = await this.stripe.subscriptions.update(
latestSubscription.id, // Your subscription ID
{
items: [
{
id: latestSubscription.items.data[0].id, // Your subscription item ID
price: 'price_1Pt1upFrwl37tCGiM5WDfpYa', // Your new price ID
},
],
default_payment_method: paymentMethodId,
expand: ['latest_invoice.payment_intent'],
},
);
In https://dashboard.stripe.com/invoices/in_1Pt1sHFrwl37tCGiY1NnjRIy, the invoice amount is $0. Payment Intent will only be created when the amount is non-zero.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
but once I get the client secret then I can use confirmCardPayment on frontent and charge the customer
but I am attaching the price_id whose value is greater then 0 usd
There is no amount to charge to the customer here, so confirm payment is not applicable here
In https://dashboard.stripe.com/invoices/in_1Pt1sHFrwl37tCGiY1NnjRIy, there is a customer balance applied to the invoice, so payment is not required
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
so how can I charge the customer once customer upgrade its plan?
When there is no customer balance on the customer, then the customer will be charged for the upgrade
If there is customer balance on the customer, Stripe will first use the customer balance to offset the payment
but my problem is the same
how can I handle it as developer
on frontend I am using confirmCardPayment which required client_secret
becuase this is how I can crharge the customer by its payment method that he saved earlier
Do you understand my point?
When the Payment Intent is null, then you don't return the client secret and confirmCardPayment() is not needed to be called
When the payment is required, Payment Intent will be available, then your system can then return client secret to frontend and use confirmCardPayment()
In summary:
- Payment Intent is null > do nothing
- Payment Intent is not null > return client secret to frontend and confirm card payment
got it
my next question is if payment_intent is null
how the customer will charged and how he can perform 3DS?
If Payment Intent is null, no payment will be charged, thus no 3DS
3DS will only be performed when there is a Payment Intent
got it
but the question remains the same
how customer will charged
if payment_intent = null
because he upgraded the subscription and for that he has to pay
do you understand my concern?
Take https://dashboard.stripe.com/invoices/in_1Pt1sHFrwl37tCGiY1NnjRIy as an example, user has to pay $118.88 when updating the subscription. However, its customer balance has credit on the customer. So Stripe will use the balance from the customer first instead of asking the customer to pay
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Only when there is no customer balance on the account, then customer will be charged
If you try to upgrade a subscription without customer balance (https://docs.stripe.com/billing/customer/balance), customer will be asked to pay and payment intent will not be null
The issue here is not with the upgrade, but the customer balance is available on this customer, so Stripe will use the credit balance to offset the upgrade amount instead of charging to customer's card
I'd recommend checking how Customer Balance works in this guide: https://docs.stripe.com/billing/customer/balance
so it mean my implementation is correct
stripe will charge the customer in the next recurring payment?
From the subscription you shared, the behaviour is expected. Stripe will charge the customer with the upgraded plan amount in next month. I'd recommend using test clock to test this scenario: https://docs.stripe.com/billing/testing/test-clocks
"Stripe will charge the customer with the upgraded plan amount in next month"
or the bnest recurring payment date?
and can I change this behavior?
that must use customer card to charge the payment
or the bnest recurring payment date?
Next billing cycle to be exact
that must use customer card to charge the payment
I'm afraid this is not possible. If there is customer balance available, Stripe will use the customer balance first instead of charging to the card
this is my card I am using it on live
but I dont have balance to my subscription
The customer associated to the subscription has been deleted, so the customer balance history can't be viewed
So I can't view how the customer balance was credited to this customer
I have another question
lets say stripe payment_intent is null
and after some time stripe try to charge oit from customer balance
I want that webhook so I can do appropiate actions
if charged failed or charged approved
invoice.payment_succeeded event will be sent even if the payment is done with customer balance, e.g. https://dashboard.stripe.com/events/evt_1Pt1sIFrwl37tCGiuVNSEeAY
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
can I use invoice.payment_succeeded or invoice.payment_failed
Yes! invoice.payment_succeeded and invoice.payment_failed events should be used
and on that I can perform downgrade or upgrade
by this I stop user to abuse my subscriptions
right?
by this I stop user to abuse my subscriptions
I'm not sure what you meant.invoice.payment_*events indicate the payment outcome of an invoice. They can be used to determine whether a payment is made successfully, then further update to your system to keep track the payment status upon an upgrade or downgrade
got it