#gopi_67606
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. 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.
- gopi_67606, 16 hours ago, 31 messages
- gopi_67606, 6 days ago, 20 messages
hello! how can I help?
Hii I have made integration for the recurring payment But it is working with the test cards & not working with live cards?
why?
what's not working?
I am unable to create the subscription with live card details
what's the exact error message?
if you reach out to Stripe Support - https://support.stripe.com/contact, they'll be able to advise you on your questions! We mainly help with developers who want to integrate directly with the Stripe API here on this channel
This customer has no attached payment source or default payment method. Please consider adding a default payment method. For more information, visit https://stripe.com/docs/billing/subscriptions/payment-methods-setting#payment-method-priority
Are you a developer?
Yes
can you share the request id [0] where the request to create the Subscription is failing? it'd look like req_xxx
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Wait
req_jdahlCDP7YimXE
This customer has no attached payment source or default payment method
Can I know how to set the default payment method after creating the customer?
Create the Subscription with payment_behavior=default_complete and also set payment_settings.save_default_payment_method = on_subscription
I'd recommend following this guide for building your subscription integration : https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements
For customer payment_behavior=default_complete
I need to attach this?
you can read up more about payment_behavior here : https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_behavior
and save_default_payment_method here : https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_settings-save_default_payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
The above links are not useful
why not?
We are doing the subscription through stripe Api code
For that subscription is creating but the default payment method is not assigning to the customer
const customer = await stripe.customers.create({
email: email,
name: name,
})
const subscription = await stripe.subscriptions.create({
customer: customer.id,
items: [{
price: planId == 3 ? environment.priceId : environment.pId, // Replace with your product's price ID
},],
});
This guide (https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements) specifically goes through how to collect the payment method for your customer and what parameters to set when creating the subscription so that the default_payment_method is automatically set when the customer makes payment for an invoice. It covers how to set up your integration end to end.
In your code snippet above, you haven't collected a payment method yet.
How are you collecting a payment method from your customer? Have you set up your application to do so yet?
Subscription has created by using the above link stuff but the subscription is in incomplete mode
Here is the subscription Id : sub_1OAT7TD6fLV2vwHg4AuFl1Lo
have you collected a payment method from the customer?
Have you gone through the link to this guide which I shared? https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements
This guide goes through how to setup your Subscription integration end to end
In line 37 {
id: 'cus_OyQ7TECkbonmhq',
object: 'customer',
address: null,
balance: 0,
created: 1699517242,
currency: null,
default_source: null,
delinquent: false,
description: null,
discount: null,
email: 'student0141@gmail.com',
invoice_prefix: '432DCBE9',
invoice_settings: {
custom_fields: null,
default_payment_method: 'pm_1OATGmD6fLV2vwHg9hdILsEo',
footer: null,
rendering_options: null
},
livemode: false,
metadata: {},
name: 'std one',
next_invoice_sequence: 1,
phone: null,
preferred_locales: [],
shipping: null,
tax_exempt: 'none',
test_clock: null
}
I am collecting the payment method for that customer
And also I am not sure is this correct or not?
that isn't the recommended way to collect the payment method for a customer
Follow the steps set out in the guide that I've linked
In the above link you are just creating the customer only right?
Have you went through this guide? https://stripe.com/docs/billing/subscriptions/build-subscriptions
I am unable to understood that
what do you not understand?
Can I use createSource method to collect the payment method?
stripe.customers.createSource(
customer.id,
{
source: "tok_visa",
},
async function (err, card) {
if (err) {
} else {
customer.default_payment_method = paymentMethodId
const subscription = await stripe.subscriptions.create({
customer: customer.id,
items: [{
price: planId == 3 ? environment.priceId : environment.pId, // Replace with your product's price ID
},],
});
res.json({ success: true, subscription, customer, planId });
}
}
);
The above one is correct?
No, you shouldn't be using createSource to collect the PaymentMethod. Depending whether you want to use Stripe Checkout (which is a Stripe hosted page), or if you want to build a more customized flow (Payment Element) - you would use one of these to collect the payment method from the Customer. Your customer needs to fill up the details on your frontend (website) to create a payment method
I have paymentMethod Id from the front end
After then How I gonna integrate with default payment metrhod for that customer?
I am collecting the details & I have payment method Id?
We are collecting the data from the front end (Payment method Id ) then after I am creating the customer but the problem is I need to integrate the customer with that payment method
You are using the Card Element, creating a PaymentMethod from the input from the Element, and then attaching the PaymentMethod directly to the Customer - This is strongly discouraged because the collected payment method isn't setup properly for future usage. You should use either a PaymentIntent or SetupIntent to save and automatically attach the Customer's PaymentMethod.
In that guide I shared, you would
- Create the Customer
- Create the Subscription
- Use the Subscription's PaymentIntent to collect the customer's PaymentMethod details which will at the same time, automatically attach and set that payment method as the default
You might want to consider using the Stripe hosted page to have your customers sign up for subscriptions instead. It's way easier to get up and running : https://stripe.com/docs/billing/quickstart
payment_intent: {
id: 'pi_3OATxSD6fLV2vwHg12Kp7RYJ',
object: 'payment_intent',
amount: 100,
amount_capturable: 0,
amount_details: [Object],
amount_received: 0,
application: null,
application_fee_amount: null,
automatic_payment_methods: null,
canceled_at: null,
cancellation_reason: null,
capture_method: 'automatic',
client_secret: 'pi_3OATxSD6fLV2vwHg12Kp7RYJ_secret_isvm8TiMF2oKhgcf3H2HQvyzg',
confirmation_method: 'automatic',
created: 1699519886,
currency: 'usd',
customer: 'cus_OyQp93ojiqTPd6',
description: 'Subscription creation',
invoice: 'in_1OATxSD6fLV2vwHgUl1Te6ft',
last_payment_error: null,
latest_charge: null,
livemode: false,
metadata: {},
next_action: null,
on_behalf_of: null,
payment_method: null,
payment_method_configuration_details: null,
payment_method_options: [Object],
payment_method_types: [Array],
processing: null,
receipt_email: null,
review: null,
setup_future_usage: 'off_session',
shipping: null,
source: null,
statement_descriptor: null,
statement_descriptor_suffix: null,
status: 'requires_payment_method',
transfer_data: null,
transfer_group: null
},
This is the payment Intent generated while created the subscription
Now Can I know how to set the payment details as default ?
you would pass the client_secret to your frontend, then you can confirm the Card Payment on your site with https://stripe.com/docs/js/payment_intents/confirm_card_payment
payment_method: {
card: elements.getElement(CardElement)
}
});