#Durrell-source
1 messages ยท Page 1 of 1 (latest)
yes
gotcha, seems like you're passing the connected account ID as part of the body rather than in the header
oh wait you're using Stripe.js
correct. The call is working on the server. Just not the client
How are you initializing Stripe.js?
Are you passing in the header as an option?
https://stripe.com/docs/js/initializing#init_stripe_js-options-stripeAccount
yes I am. I'm also seeing the connected account's stripe_account in the Headers from the request in my network tab in Chrome.
can you share the example code?
const stripe = window.Stripe(stripePublishableKey, {
stripeAccount: 'acct_1LKW3xQsplVDpaCb'
})
huh not seeing why this is failing
Have you tried logging out the client secret to see if they match?
I'm not sure if this will help, but here is the request_id of the call that is working on the server: req_gdF7oqGehgwjvYest_id
I'm literally hard coding the client secret in the client for now, for test purposes.
sorry, typo. here is the request_id from the server: req_gdF7oqGehgwjvY
all good. did the hard-coding secret work?
no, it was hard coded from the begining
can you share your complete code?
I wonder if there's something minor that I'm missing here
const getStripeSource = async () => {
const stripe = window.Stripe(stripePublishableKey, {
stripeAccount: 'acct_1LKW3xQsplVDpaCb'
})
const { error, source } = await stripe.retrieveSource({
client_secret: 'src_client_secret_eOWvuQtw2PPN6bbPFrPmMwuS',
id: 'src_1LKWVcQsplVDpaCbQXX7km4G'
})
if (error) {
console.log('error', error)
}
if (source) {
console.log('source', source)
}
}
getStripeSource()
huh that does look fine ๐ค
Is there anyway your stripe object is being reinitialized somewhere?
I don't think so. Just above the code I pasted above I'm doing this:
useEffect(() => {
if (!(window as any).Stripe) {
loadStripe(stripePublishableKey)
}
return null
}, [])
Since I'm able to get the source from the server side call I can just make a call from the client to get the source from the server instead of going straight to Stripe from the client. The reason why I was trying to make this call from the client is because I was hoping to get the full account number from the client side call. The server side call only returns the last4 digits of the account number.
Does the client side call return the full account number? The source object docs show the full account number. https://stripe.com/docs/api/sources/object
For example: "account_number": "test_52796e3294dc"
I was thinking the server side call only returns the last4 for PCI compliance reasons, but I was hoping the client side call would return the full account number.
Likely that the useEffect is causing the issue here
If I put a console.log in that useEffect I can see it only loads once. For example:
useEffect(() => {
if (!(window as any).Stripe) {
console.log('Loading Stripe.js')
loadStripe(stripePublishableKey)
}
return null
}, [])
Does the client side call return the full account number?
I haven't tested this myself unfortunately so I don't know, give me a sec
So using loadStripe with useEffect isn't recommended approach here
The stripe instance is tied to a specific account, so there is no way to update the account once created. What you can do however is create another Stripe instance for the other account. Since the Elements provider component can only be tied to a single stripe instance, you'll need to instruct React to create a new component using a key prop. That will force a re-render of all children of Elements.
https://github.com/stripe/react-stripe-js/issues/107#issuecomment-657866413
Does the client side call return the full account number?
I'll test this out and let you know
okay sorry that took a while but client-side retrieval will also just give you the last 4
ok. Thank you for your time. I really appreciate it.
NP! ๐ Appreciate you patience
when I make that call on the server I get this:
"object": "source",
"ach_debit": {..."last4":"6789"}
but the docs show this:
"object": "source",
"ach_credit_transfer": {
"account_number": "test_52796e3294dc", ...}
Am I looking at the wrong object in the docs? I'm using the latest version of the Stripe gem.
HI ๐ @analog mica needed to step away so I'm stepping in. Can you share the request ID for that request?
req_gdF7oqGehgwjvY
But this source is an ACH debit payment method. So the response makes sense
ok. Thank you.