#developer_capsync

1 messages · Page 1 of 1 (latest)

teal mossBOT
chrome haven
#

Hi how can we help?

#

@blazing orchid you take the Payment Intent secret from the variable subscription. It already expands latest_invoice.payment_intent

blazing orchid
#

yes

#

I'm getting the client_secret_id after the creation of customer and subscription

#

How can i get it before creation

chrome haven
#

No you can't. Only after created the Subscription you would have the underlying PaymentIntent

blazing orchid
#

see I want to implement this but It needs secret key before the creation

blazing orchid
#

I totally agree

chrome haven
#

Yes it's the PaymentElement, I know. You need to setup an AJAX call to backend to create the Subscription, returns the PaymentIntent client secret in the AJAX response. Then you use the client secret to initialize the PaymentElement on frontend

blazing orchid
#

Thank you for your feedback

chrome haven
#

Good luck!

blazing orchid
#

Right now for confirm payment I'm using
const confirmPayment = await stripe.confirmCardPayment(
storeData.clientSecret,
{
payment_method: {
card: elements.getElement("card"),
billing_details: {
name: handleName,
// address: 'surat,gujarat'
},
},
}
);

chrome haven
#

That's the legacy Card Element

blazing orchid
chrome haven
#

The one you were looking for above is PaymentElement

blazing orchid
#

yes

#

So by using PaymentElement, is it going to work for subscription

#

?

chrome haven
#

Yes

#

It's the same, getting a client secret and supply into PaymentElement

blazing orchid
#

So in a nutshell, First we're creating a subscription and then payment

chrome haven
#

A Subscription will automatically create a PaymentIntent inside its invoice_settings.payment_intent

blazing orchid
#

ok

#

payment_intent: {
id: 'pi_3MsffESEEDxu2vd91Wllr0ui',
object: 'payment_intent',
amount: 1500,
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_3MsffESEEDxu2vd91Wllr0ui_secret_IynXJav06eIkAW56xStuGU52L',
confirmation_method: 'automatic',
created: 1680498644,
currency: 'usd',
customer: 'cus_Ndxab76XGv28Yk',
description: 'Subscription creation',
invoice: 'in_1MsffESEEDxu2vd9TcaqSg16',
last_payment_error: null,
latest_charge: null,
livemode: false,
metadata: {},
next_action: null,
on_behalf_of: null,
payment_method: 'pm_1MsffASEEDxu2vd9SYM6IfZ7',
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_confirmation',
transfer_data: null,
transfer_group: null
},

chrome haven
#
client_secret: 'pi_3MsffESEEDxu2vd91Wllr0ui_secret_IynXJav06eIkAW56xStuGU52L',

The value is here

blazing orchid
#

yes