#RohitK
1 messages · Page 1 of 1 (latest)
👋 happy to help
what kind of Charges are you using? Destination or Direct Charges?
destination charge
in that case you need to initialize the stripe instance with your publishable key and pass in the stripeAccount property
var stripe = Stripe(
'pk_test_EcEoJOTFxxxxxxxxxxxxxxxxxx800DNtPFS'
);
// Redirects away from the client
stripe.confirmAffirmPayment(
response,
{
payment_method: {
// Billing information is optional but recommended to pass in.
billing_details: {
email: 'rohitkatarya7@gmail.com',
name: 'test admin',
address: {
line1: '2609 North Rome Avenue, Tampa, FL, USA',
city: 'Tampa',
state: 'FL',
country: 'US',
postal_code: '29715',
},
},
},
// Shipping information is optional but recommended to pass in.
shipping: {
name: 'test admin',
address: {
line1: '2609 North Rome Avenue, Tampa, FL, USA',
city: 'Tampa',
state: 'FL',
country: 'US',
postal_code: '29715',
},
},
// Return URL where the customer should be redirected after the authorization.
return_url: '/checkout/success',
}
).then(function(result) {
if (result.error) {
// Inform the customer that there was an error.
console.log(result.error.message);
}
});
var stripe = Stripe( 'pk_test_EcEoJOTFxxxxxxxxxxxxxxxxxx800DNtPFS', { stripeAccount: 'acct_xxx' // Connected Account } );
IT soesn't make the code insecure ?
no
As we are showing the connected account id publically
the account ID doesn't give you access to anything
it's just an ID
it's not a secret key or anything compromising your security
and it's the only way to deal with Destination Charges on the front end
still getting the same error
would you mind sharing either the PaymentIntent ID or the request ID? https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
error: {message: "Invalid API Key provided: pk_test_****************************tPFS",…}
message: "Invalid API Key provided: pk_test_****************************tPFS"
type: "invalid_request_error"
Do you mean payment intent client secret?
Hi! I'm taking over my colleague. Please, give me a moment to catch up.
sure
Could you please share the Request ID req_xxx? https://support.stripe.com/questions/finding-the-id-for-an-api-request
I see it's a successful request. Where do you see the error?
I am getting the payment intent id and secret client successfully but when request stripe.confirmAffirmPayment() is send then it returns invalid api keys error
https://api.stripe.com/v1/payment_intents/pi_3N40eKDxx6FOEdeE1TxtdUer/confirm
API hit return me the above mentioned error
and nothing is reflecting in the logs
Are you using the public key of the Platform?
yes
Could you please double check if it's correct? Sorry, I don't see any other reason for the error.
You don't need to use the stripeAccount header, because it's a Destination Charge. Sorry for confusion.
Please, let me know if you have any other questions.
sure
I have checked it thrice, payment intent is created properly but when I am hitting https://api.stripe.com/v1/payment_intents/pi_3N40eKDxx6FOEdeE1TxtdUer/confirm it returns invalid api keys error
is it helpful if I will share the payload of this api with you
Yes
shipping[name]: test admin
shipping[address][line1]: 2609 North Rome Avenue, Tampa, FL, USA
shipping[address][city]: Tampa
shipping[address][state]: FL
shipping[address][country]: US
shipping[address][postal_code]: 29715
return_url: /checkout/success
payment_method_data[type]: affirm
payment_method_data[billing_details][email]: rohitkatarya7@gmail.com
payment_method_data[billing_details][name]: test admin
payment_method_data[billing_details][address][line1]: 2609 North Rome Avenue, Tampa, FL, USA
payment_method_data[billing_details][address][city]: Tampa
payment_method_data[billing_details][address][state]: FL
payment_method_data[billing_details][address][country]: US
payment_method_data[billing_details][address][postal_code]: 29715
payment_method_data[guid]: 91c5ef3d-7fc1-4167-8aaf-e1e6b51bfa4a15d5e8
payment_method_data[muid]: 030d2106-cb9a-43ff-a35b-4f9d30aa84048a5add
payment_method_data[sid]: f406540d-13ed-4613-8b9f-6b674668b284721272
payment_method_data[payment_user_agent]: stripe.js/89e87bca59; stripe-js-v3/89e87bca59; raw-stripe-js-api
payment_method_data[time_on_page]: 22668
expected_payment_method_type: affirm
key: pk_test_EcExxxxxxxxxxx5E0efnx800DNtPFS
_stripe_account: acct_1M2wNrRncNHbtVmb
client_secret: pi_3N4xxxxxxxxxxxxxeE0cZ3Njmj_secret_08bxxxxxxxxxxxjSmSglFuZGTAM
For some reason I don't see the confirm request related to this PI. It might be that the error comes from the Stripe.js and not from our API.
Please delete the key
How are you sending this request?
var stripe = Stripe(
'pk_test_EcEoJOxxxxxxxefnx800DNtPFS',{
stripeAccount: 'acct_1M2wNrRncNHbtVmb' // Connected Account
}
);
// Redirects away from the client
stripe.confirmAffirmPayment(
response,
{
payment_method: {
// Billing information is optional but recommended to pass in.
billing_details: {
email: 'rohitkatarya7@gmail.com',
name: 'test admin',
address: {
line1: '2609 North Rome Avenue, Tampa, FL, USA',
city: 'Tampa',
state: 'FL',
country: 'US',
postal_code: '29715',
},
},
},
// Shipping information is optional but recommended to pass in.
shipping: {
name: 'test admin',
address: {
line1: '2609 North Rome Avenue, Tampa, FL, USA',
city: 'Tampa',
state: 'FL',
country: 'US',
postal_code: '29715',
},
},
// Return URL where the customer should be redirected after the authorization.
return_url: '/checkout/success',
}
).then(function(result) {
if (result.error) {
// Inform the customer that there was an error.
console.log(result.error.message);
}
});
}
using this code
As I mentioned earlier, you don't need to use the stripeAccount header
What's in the response variable?
stripe.confirmAffirmPayment(
response,
it will return the payment_intent_cient_secret
without stripeAccount header also it is not working
Giving same error
I understand, but you still should not use it because it will make the issue harder to investigate.
Where do you take the publishable key from?
I have removed it now.
I am using the platform publishable key.
As my stripe connect without affirm is working fine.
I was integrating stripe affirm option in it now.
and facing the invalid API Key provided error. But simple stripe connect is working fine with the same key values
Are you able to confirm other payment methods? Like card?
yes initially I was using the card payment only in stripe connect.
I am looking at your account and I see that your publishable key is not correct.
Can you please grab the publishable key from the Dashboard?
https://dashboard.stripe.com/test/apikeys