#kirubakaran - Null client secret
1 messages · Page 1 of 1 (latest)
evt_3KWPaaFx11m8e94j1A5O5tza
The object in the event data has a valid client secret from what I can see
Here is the object I see when I examine this event
object: {
id: "pi_xxxx",
object: "payment_intent",
allowed_source_types: [
"card"
],
amount: 100,
amount_capturable: 0,
amount_received: 0,
application: null,
application_fee_amount: null,
automatic_payment_methods: null,
canceled_at: null,
cancellation_reason: null,
capture_method: "automatic",
charges: {
object: "list",
data: [],
has_more: false,
total_count: 0,
url: "/v1/charges?payment_intent=pi_xxxx"
},
client_secret: "pi_xxxx_secret_xxxxxx",
confirmation_method: "automatic",
created: 1645640964,
currency: "usd",
customer: "cus_xxxx",
description: "Invoice F2267445-0006",
invoice: "in_xxxx",
last_payment_error: null,
livemode: true,
metadata: {},
next_action: null,
next_source_action: null,
on_behalf_of: null,
payment_method: null,
payment_method_options: {
card: {
installments: null,
network: null,
request_three_d_secure: "automatic"
}
},
payment_method_types: [
"card"
],
processing: null,
receipt_email: null,
review: null,
setup_future_usage: null,
shipping: null,
source: null,
statement_descriptor: null,
statement_descriptor_suffix: null,
status: "requires_source",
transfer_data: null,
transfer_group: null
}
{
"object": {
"id": "pi_3KWPaaFx11m8e94j1jpVmILD",
"object": "payment_intent",
"amount": 100,
"amount_capturable": 0,
"amount_received": 0,
"application": null,
"application_fee_amount": null,
"automatic_payment_methods": null,
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "automatic",
"charges": {
"object": "list",
"data": [
],
"has_more": false,
"total_count": 0,
"url": "/v1/charges?payment_intent=pi_3KWPaaFx11m8e94j1jpVmILD"
},
"client_secret": null,
"confirmation_method": "automatic",
"created": 1645640964,
"currency": "usd",
"customer": "cus_LBHahZAoIO56eF",
"description": "Invoice F2267445-0006",
"invoice": "in_1KWPaYFx11m8e94jaPYvG3hk",
"last_payment_error": null,
"livemode": true,
"metadata": {
},
"next_action": null,
"on_behalf_of": null,
"payment_method": null,
"payment_method_options": {
"card": {
"installments": null,
"network": null,
"request_three_d_secure": "automatic"
}
},
"payment_method_types": [
"card"
],
"processing": null,
"receipt_email": null,
"review": null,
"setup_future_usage": null,
"shipping": null,
"source": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "requires_payment_method",
"transfer_data": null,
"transfer_group": null
}
}
this is what showing to me
Hmmmm.... 🤔
😩
The client secret is not intended to persist on you end but be used to authenticate the front-end when using Stripe.js elements. What do you want it for?
i am using paymentindent.created to get the client_secret and using it in the stripe element to confirm the payment, as it is returniing as null i cannot able to make payments
Where are you creating the paymentIntent?
i am using this paymentindent.created webkook to get the client_secret
Okay but when are you creating the paymentIntent?
i am not creating paymentindents, i am trying to get the payment indent id and secret_code of invoice created in subscription in connect account
Webhooks are not intended for that purpose. Client secrets should be sent from the server creating the payment intent to the front-end consuming it. How is your application designed?
thats how we used but how can we pay the stripe subscription invoice with our own custopm payment page with stripe emements without client secret
What I am asking is, how do your server-side and client-side portions of you app communicate?
i am seding data using rest api
So, as this diagram displays (https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements#web-create-intent), the Payment Intent is generated on the sever and the client secret is provided to the front-end from the server.
I don't think webhooks are an appropriate method for accessing the client_secret
then how can i able to get the client secret of the invoice created by stripe subscription
The invoice object includes the payment Intent, which can be expanded to return the client secret: https://stripe.com/docs/api/invoices/object#invoice_object-payment_intent
@vapid ice when your server receives the event, if you need the client_secret you can retrieve the object from the API bfore taking whatever client-side action is needed
@wind fjord i am doing that only...but i am receiving null in client_secret in the event
yes, you need to explicitly retrieve the object
ok ...ca you please give any axample for this
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
If you take a look there, we show an example for each client language
Do you also use one-time payment intents, or only subscriptions / invoices?
Can you share the request id? eg req_123
( https://stripe.com/docs/api/request_ids)
Ok in that case you might want to look at invoice specific events so that you don't unintentionally handle non-invoice payment intents
What scenario are you trying to handle?
do you mean event_id
No, I mean the request you make to retrieve the invoice or payment intent object
I think it might be worth taking a step back and explaining to me your broader flow here. At a high level, what are you trying to do?
I am trying to get the client_secret from paymentindent.created webhooks and i am passing it to stripe element confirm payment api,,,but here i am getting the cleint secret as null,, so i cant able to make any payments as the client_secret is null
OK take a step back from that, why do you want to do that?
What problem are you trying to solve?
hi @wind fjord ..
we are using stripe connect in our application
to make transaction between our customers...
i tried using await stripe.paymentIntents.retrieve("pi_3KWPaaFx11m8e94j1jpVmILD",{stripeAccount :"acct_1Bdd4RFx11m8e94j"})
but it also returning client_secret as null
@wooden briar Sure but what flow are you using for this? ie, who creates a subscription, how, which invoices are you trying to handle, etc
example: user A is our customer..
@vapid ice OK great - that's this request: https://dashboard.stripe.com/logs/req_Nkk7QxosODEhoF
he will create subscription or invoices for user B...
user A will connect with stripe using their stripe account..
after that they will start create subscription and invoices to their customers..
yes
Can you try doing an update to that payment intent to set some metadata? eg:
stripe.paymentIntents.update("pi_3KWPaaFx11m8e94j1jpVmILD", {metadata: {testkey: 'testvalue'}},{stripeAccount :"acct_1Bdd4RFx11m8e94j"})
You should see your metadata in the response, in addition to the client secret
no...i am not updating
do i need to do this
await stripe.subscriptions.create({
customer: customer_id,
items: [{ price: price_id }],
collection_method: "send_invoice",
days_until_due: 10
expand: ["latest_invoice.payment_intent"],
}, { stripeAccount: account_id })
this is what i am using to create subscription and its invoices are auto generated right?
That's another option, yes! But, that is suing "send invoice" to send the user emails to pay on the hosted invoice page. What are you trying to do with the client secret here?
If you're trying to build a custom payment flow you should use collection_method=charge_automatically
what if i dont't have credit card details by default
What do you mean?
tried updating paymentindent
{
id: 'pi_3KWPaaFx11m8e94j1jpVmILD',
object: 'payment_intent',
amount: 100,
amount_capturable: 0,
amount_received: 0,
application: null,
application_fee_amount: null,
automatic_payment_methods: null,
canceled_at: null,
cancellation_reason: null,
capture_method: 'automatic',
charges: {
object: 'list',
data: [],
has_more: false,
total_count: 0,
url: '/v1/charges?payment_intent=pi_3KWPaaFx11m8e94j1jpVmILD'
},
client_secret: null,
confirmation_method: 'automatic',
created: 1645640964,
currency: 'usd',
customer: 'cus_LBHahZAoIO56eF',
description: 'Invoice F2267445-0006',
invoice: 'in_1KWPaYFx11m8e94jaPYvG3hk',
last_payment_error: null,
livemode: true,
metadata: { testkey: 'testvalue' },
next_action: null,
on_behalf_of: null,
payment_method: null,
payment_method_options: {
card: {
installments: null,
network: null,
request_three_d_secure: 'automatic'
}
},
payment_method_types: [ 'card' ],
processing: null,
receipt_email: null,
review: null,
setup_future_usage: null,
shipping: null,
source: null,
statement_descriptor: null,
statement_descriptor_suffix: null,
status: 'requires_payment_method',
transfer_data: null,
transfer_group: null
}
I'd be better able to help if you could describe your overall expected flow. I think you're questions are too narrowly focused and aren't really addressing your bigger objective.
still getting client_secreat as null
OK, interesting. Let me look into this.
@vapid ice @wooden briar Is this something new you're building, or an existing integration that stopped working?
ie, is this changed behaviour to you, or something you discovered during development?
OK we found that this is different than it was recently, still investigating