#L0rdandBooz
1 messages · Page 1 of 1 (latest)
What's your question?
I keep receiving this error:
message: "No such PaymentMethod: 'pm_1NWBcZLQhKtna1xjw9ERSxaC'; OAuth key or Stripe-Account header was used but API request was provided with a platform-owned payment method ID. Please ensure that the provided payment method matches the specified account.",
param: 'payment_method',
request_log_url: 'https://dashboard.stripe.com/acct_1MQNUuQ6PD4queU4/test/logs/req_3ERDGqUdoHABbX?t=1689916698',
Here is where I'm creating my payment method on the front end:
const cardElement = elements.getElement(CardNumberElement);
const tempresult = await stripe.createPaymentMethod({
type: 'card',
card: cardElement,
}, {stripeAccount: connectedAccount.data});
and here is where I'm calling the function on the backend
if (customerExists) {
customerId = customerExists?.stripeCustomerID;
} else {
const customer = await stripe.customers.create({
email: email,
name: ${firstName} ${lastName},
phone: phone,
description: donateAsOrganization ? Organization Name: ${organizationName} : '',
},
{stripeAccount: connectAccountID,
});
customerId = customer.id;
}
// Attach the payment method to the customer
await stripe.paymentMethods.attach(
paymentMethodID,
{ customer: customerId },
{ stripeAccount: connectAccountID },
);
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
This is happening because the payment method pm_1NWBcZLQhKtna1xjw9ERSxaC exists on the platform account but you're making the request on the connect account (so we can't find the payment method)
{ stripeAccount: connectAccountID }, indicates you're making the request on the connect account
Right and that makes total sense but when I create the payment method I'm passing the connect account. Is there a different syntax I should be using?
const cardElement = elements.getElement(CardNumberElement);
const tempresult = await stripe.createPaymentMethod({
type: 'card',
card: cardElement,
}, {stripeAccount: connectedAccount.data});
Oh you're creating the payment method from the frontend
In that case, you'd want to initialize the elements object as the connect account instead: https://stripe.com/docs/js/initializing#init_stripe_js-options-stripeAccount
would I be better off passing the token to the backend and creating from there? Security wise?
What's the reason you're creating the payment method explicitly?
Our recommended payment flow doesn't do it that way: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
I want to allow for recurring payments and or text to donate capabilities for my customers. It is a donation platform.
So I'm wanting to store the payment method on a customer for future use