#april_error
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฑ๏ธ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime!
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1212139438818201600
๐ Have more to share? You can add more detail below, including code, screenshots, videos, etc.
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question. Thank you for your patience!
for additional context see https://discord.com/channels/841573134531821608/841573134531821616/threads/1211736661990441041
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
Hello ๐
I can't seem to load the other thread you linked above
hmm, it was from yesterday in the dev-help channel
Are you using the Direct Charges flow or Destination Charges flow?
Can you share the code you're using on your client-side and server-side?
message link: #dev-help message
Are you using the Direct Charges flow or Destination Charges flow?
Direct
Can you share the code you're using on your client-side and server-side?
part of it sure,
backend service
func (s *svc) create(
ctx context.Context,
input stripe.PaymentIntentParams,
) (*stripe.PaymentIntent, error) {
logger := s.getLogger(ctx)
logger.Info("Creating payment intent")
acc, err := s.db.ConnectedAccountRead(ctx, &model.ConnectedAccount{Type: model.ConnectedAccountTypeStripe})
if err != nil {
logger.Error("failed to get connected account from db", zap.Error(err))
return nil, err
}
input.SetStripeAccount(acc.ExternalID)
return s.StripeAPI.PaymentIntents.New(&input)
}
merchant backend
const paymentIntent = await CreatePaymentIntent( {
amount: totalAmount || amount,
currency,
metadata,
payment_method_configurations: "pmc_1OkY1PJte4cqQKEB7PmSneVd",
},{"Idempotency-Key":idempotencyKey}).catch((err) => {
console.error(`pi/c Error creating Payment Intent: ${err}`);
throw new Error(`Error creating Payment Intent: ${err}`);
});
export async function CreatePaymentIntent(body: object, headers: object):Promise<Stripe.PaymentIntent> {
const endpoint = process.env
.NEXT_PUBLIC_NACELLE_NOMS_ORDER_ENDPOINT as string;
const spaceId = process.env.NEXT_PUBLIC_NACELLE_SPACE_ID as string;
try {
//combine headers
const h = Object.assign({
Authorization: 'Bearer ' + (await getAuthToken()),
'Content-Type': 'application/json',
'X-Nacelle-Space-ID': spaceId,
}, headers);
// console.log('WriteOrder Body: ', JSON.stringify(body));
const resp = await fetch(endpoint + `/paymentintent/create`, {
method: 'POST',
headers: h,
body: JSON.stringify(body)
});
// console.log('WriteOrder:', resp);
return await resp.json();
} catch (e) {
console.error(e);
}
return {} as Stripe.PaymentIntent;
}
merchant frontend
{stripeClientSecret && (
<Elements
stripe={stripePromise}
options={{
// @ts-ignore
paymentMethodCreation:"manual",
clientSecret: stripeClientSecret
}}
>
<PaymentForm clientSecret={stripeClientSecret}
isShippingEntered={isShippingEntered}
setIsShippingEntered={setIsShippingEntered}
shippingOptions={shippingOptions}
setShippingAddress={setShippingAddress}
shippingAddress={shippingAddress}
/>
</Elements>
)}
Are you setting Stripe-Account header on the client-side too when you initialize Stripe?
merchant backend stripe init
import Stripe from 'stripe';
export default new Stripe(process.env.STRIPE_SECRET_KEY as string, {
// https://github.com/stripe/stripe-node#configuration
apiVersion: '2023-10-16',
typescript: true,
maxNetworkRetries: 5
});
merchant frontend stripe init
const stripePromise = loadStripe(
process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY as string
);
Are you setting Stripe-Account header on the client-side too when you initialize Stripe?
Which account would that be?
The same account that you're setting server-side when creating the PaymentIntent
return s.StripeAPI.PaymentIntents.New(&input)
}```
ah okay through the StripeConstructorOptions during loadstripe?
something like
const stripePromise = loadStripe(
process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY as string,
options:{
stripeAccount: "acct_..."
}
);
yeah look at the doc link I shared. it has a react example
ah okay, hmm is the
STRIPE_PUBLISHABLE_KEY
should that be the connected accounts key or the main accounts key, the linked docs makes me think its the main account?
That would be the key that belongs to the Platform account, yes
hmm a different error now
{
"type": "invalid_request_error",
"message": "The client_secret provided does not match any associated PaymentIntent on this account. Ensure the publishable key used belongs to the same account that created the PaymentIntent.",
"param": "client_secret",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_zDz4RI1NLPerMX?t=1709068566",
"status": 400
}
so my frontend is using
const stripePromise = loadStripe(
process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY as string,
{
stripeAccount: process.env.STRIPE_ACCOUNT_ID as string
}
);
where the publishable key is my platforms key and the STRIPE_ACCOUNT_ID is the connected account id.
Oh hmm. Can you share the PaymentIntent ID you're using for this?
pi_3OoY0QJte4cqQKEB0zrCQqu1
Are you sure the Stripe-Account header value is being set correctly?
The error is indicating that you're looking for pi_3OoY0QJte4cqQKEB0zrCQqu1 on the platform account where as it exists on the connected account acct_1OLBxnJte4cqQKEB
so it seems like the env variable isn't setting the connected account ID correctly
can you try hard-coding it?
๐คฏ well that worked. I think i should be good to go, i need to see if i can confirm the payment still but i need to get my local into a better state to test that. Thanks for the help ๐ฅณ