#developer_capsync
1 messages · Page 1 of 1 (latest)
Hi how can we help?
@blazing orchid you take the Payment Intent secret from the variable subscription. It already expands latest_invoice.payment_intent
yes
I'm getting the client_secret_id after the creation of customer and subscription
How can i get it before creation
No you can't. Only after created the Subscription you would have the underlying PaymentIntent
see I want to implement this but It needs secret key before the creation
I understand your point
I totally agree
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
Thank you for your feedback
Good luck!
FYI it should be similar to this step: https://stripe.com/docs/payments/quickstart#fetch-payment-intent
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'
},
},
}
);
That's the legacy Card Element
correct
The one you were looking for above is PaymentElement
So in a nutshell, First we're creating a subscription and then payment
A Subscription will automatically create a PaymentIntent inside its invoice_settings.payment_intent
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
},
client_secret: 'pi_3MsffESEEDxu2vd91Wllr0ui_secret_IynXJav06eIkAW56xStuGU52L',
The value is here
yes