#leedurrant-bring-customer-back
1 messages ยท Page 1 of 1 (latest)
Hello ๐
Can you provide specific examples for the PaymentIntent as well as the code that you're using and walk me through the flow?
pi_3LNdBvL4KF1uRfCk0EkGgFXZ
How are you initializing Stripe exactly?
var stripe = Stripe("pk_test_x_mypk_x");
$( document ).ready(function() {
document.querySelector("#authenticate")
.addEventListener("click", function(evt) {
var clientSecret = "pi_3LNdBvL4KF1uRfCk0EkGgFXZ_secret_12345";
var paymentMethodId = "card_12345";
//showEl(".requires-auth");
changeLoadingState(true, "#authenticate");
stripe
.confirmCardPayment(clientSecret, {payment_method: paymentMethodId})
.then(function(stripeJsResult) {
changeLoadingState(false, "#authenticate");
if (stripeJsResult.error && stripeJsResult.error.code === "payment_intent_authentication_failure") {
// Authentication failed -- prompt for a new payment method since this one is failing to authenticate
setupElements();
//hideEl(".requires-auth");
//showEl(".requires-pm");
} else if (stripeJsResult.paymentIntent && stripeJsResult.paymentIntent.status === "succeeded") {
// Payment was authenticated and the card was charged
paymentIntentSucceeded(clientSecret, ".requires-auth");
}
});
});
});
Ah I see
You'd likely want to look into initializing with Stripe-Account header as shown in the example here
https://stripe.com/docs/connect/authentication
https://stripe.com/docs/connect/authentication#adding-the-connected-account-id-to-a-client-side-application
Ah of course. I have some MOTO code that uses stripe.js and it works fine. And now that you responded I know realise how stupid I have been!
But....
Is it safe to put the CONNECTED_STRIPE_ACCOUNT_ID in to the html?
yup that's fine ๐
Cool. The moto stuff doesn't really expose the html, and even if they could grab it, it would be the merchant viewing his own account. Many thanks for such a quick response.