#bhanu365-question-thread
1 messages ยท Page 1 of 1 (latest)
Hi @radiant raft ๐ roadrunner is not online currently. Can you summarize your question and we can start a new thread? I'll reference the old one for additional context if needed
Ok let me explain again
I am creating a subscription module where customers can buy a plan for 1 month, 6 months, and 12 months, and there is auto-renewal functionality as well.
- How can store the card details for auto-renewal payment?
- Is this the correct API method that I am doing?
I just saved customer ID only, When I use a different card detail from testing cards like 4000000000000069 (Expired) then I am getting an error, Like "You haven't attached customer ID with source" or something like this.
I just want any customer can buy a plan and we can save card details and we will not show card form anymore if we have their card details and when their subscription plan ends so it can easily auto-renewal.
I am not familier with the stripe
"roadrunner" has shared some links
but the I am confuse what I do first
Like when I create card element
what the next step
I need to Call paymentMenthod or something else
I am bit confuse
Okay, that's a lot and I'm having trouble understanding what's going wrong.
When I use a different card detail from testing cards like 4000000000000069 (Expired) then I am getting an error, Like "You haven't attached customer ID with source" or something like this.
That error is expected, because you cannot attach a payment method that is expired.
If you''re just starting out I would recommend using the Payment element instead of the card element: https://stripe.com/docs/payments/quickstart
If you must use the card element, then I'd suggest following this quickstart guide for using the card element:
https://stripe.com/docs/payments/card-element
I already wastes 3 days on it
I'm happy to help, but I don't know what you're looking for. The docs show how to build a fully functioning subscription integration, so I'm not sure where you're running into issues.
Can you elaborate more on what you're asking?
const btn = document.querySelector('#submit-payment-btn');
btn.addEventListener('click', async (e) => {
e.preventDefault();
const nameInput = document.getElementById('name');
// Create payment method and confirm payment intent.
stripe.confirmCardPayment(clientSecret, {
payment_method: {
card: cardElement,
billing_details: {
name: nameInput.value,
},
}
}).then((result) => {
if(result.error) {
alert(result.error.message);
} else {
// Successful subscription payment
}
});
});
Are you recommending this code I need to use for it?
As last roadrunner tole me to use this one method
Then I was asking I need to pass "clientSecret" in the payment element
but I don't know how I will get the clientSecret ID
In step 5 of the docs you referenced, the Subscription you created will have a Payment Intent attached to it with a client secret field you can use
This line here should be in your code from the snippets you copied already
clientSecret: subscription.latest_invoice.payment_intent.client_secret,
@fathom grove is going to be taking over for me, so they will be able to handle any follow up questions going forward.
Ok
But according to the Doc, I can get clientSecret after subscription create but I am little confused because subscription create method will run after click on the payment element button but before the load of payment element I need clientSecret
It's bit confusion
@fathom grove
๐
@fathom grove Or I need to call create subscription method on selection of plan?
Sorry several people on the server
So yes
With Payment Element you must have the client secret to render the Element
That means you want to create the Subscription once the customer chooses the Product they want to buy. Then you render the Payment Element
Got it thanks
So after that I will create a customer or paymentIndent?
I think I need to create customer than will attach with paymentIndent
I just need to know the flow of subscription and auto renewal process then I can implement easily after understanding the flow
Have you read through https://stripe.com/docs/billing/subscriptions/build-subscriptions?
That walks you through each step here
Flip to the "custom code" option at the top
And it will walk you through how to integrate Subsriptions using Payment Element
There are a lot of code, I already tried so many time to understand but I'm unable to understand, Can you just tell me what will be the next step when customer click on the the submit button to pay, Which method I need to call.
You call stripe.confirmPayment() when the customer clicks on your Pay button
And what I need to do after the call "stripe.confirmPayment() "
Well you need Webhooks to handle fulfillment
So how the auto renewal work? how the payment will deduct when a subscription ends.
And what will be if a customer card has expired or a customer want to update their card details
When you create the Subscription you set payment_settings: { save_default_payment_method: 'on_subscription' }, (as noted in the guide above)
This saves the PaymentMethod that was used for initial payment as the Subscription default
And it will be charged upon renewal
You can then set up how you want to handle failed payments in your Settings in your Dashboard: https://dashboard.stripe.com/settings/billing/automatic
Ok, thanks let me try to implement and then will let you know If I face any issues.
๐
Can I discount the amount on our end on the when auto-renewal payment will be deduct
Hi ๐
I'm stepping in as @fathom grove had to go.
What are you trying to achieve?
Like if a teacher have multiple referrals ans 1 referral means 10% discount in the subscription if teacher have 10-15 referrals so when the teacher's subscription is about to be auto-renewal, then the discount of referral should be applied in it.
Okay so you would want to apply a Coupon to that Customer record. We mention that here: https://stripe.com/docs/billing/subscriptions/coupons#discount-customers
No I don't want to apply coupon
I just want to apply discount amount of percentage on subscription plan amount
We are storing the referral amount as a balance
when the teacher's subscription is about to be auto-renewal then all the referral balance as a discount will be applied related to that susbscription
Okay so then you could specify a credit balance for the customer but you would need to calculate the amount. This would be something you would create after the invoice is created but before the customer is billed. Auto-renewal invoices are in Draft state for 1 hour to allow your integration time to perform these actions
https://stripe.com/docs/api/credit_notes/create
Can we start the discussion in the morning with the same thread?
This thread will be archived by then but you can request it be re-opened.
From which person do I need to request to reopen the thread
Whoever is here from Stripe
Ok thanks