#gopi_67606

1 messages · Page 1 of 1 (latest)

wise irisBOT
#

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.

stable radish
#

hello! how can I help?

last rain
#

Hii I have made integration for the recurring payment But it is working with the test cards & not working with live cards?

#

why?

stable radish
#

what's not working?

last rain
#

I am unable to create the subscription with live card details

stable radish
#

what's the exact error message?

last rain
#

Its not returning any error

#

The payment is not getting successful

stable radish
#

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

last rain
stable radish
#

Are you a developer?

last rain
#

Yes

stable radish
last rain
#

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?

stable radish
#

Create the Subscription with payment_behavior=default_complete and also set payment_settings.save_default_payment_method = on_subscription

last rain
#

For customer payment_behavior=default_complete
I need to attach this?

stable radish
#
last rain
#

The above links are not useful

stable radish
#

why not?

last rain
#

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   
    },],
  });
stable radish
#

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.

Create and manage subscriptions to accept recurring payments.

#

How are you collecting a payment method from your customer? Have you set up your application to do so yet?

last rain
#

Subscription has created by using the above link stuff but the subscription is in incomplete mode

#

Here is the subscription Id : sub_1OAT7TD6fLV2vwHg4AuFl1Lo

stable radish
#

have you collected a payment method from the customer?

last rain
#

No, How do we collect that ?

#

I am new to the stripe integartion'

stable radish
#

This guide goes through how to setup your Subscription integration end to end

last rain
#

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?

stable radish
#

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

last rain
#

In the above link you are just creating the customer only right?

stable radish
last rain
#

I am unable to understood that

stable radish
#

what do you not understand?

last rain
#

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?

stable radish
#

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

last rain
#

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

stable radish
#

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

  1. Create the Customer
  2. Create the Subscription
  3. 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
last rain
#

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 ?

stable radish