#L0rdandBooz

1 messages · Page 1 of 1 (latest)

teal heathBOT
vivid parcel
#

What's your question?

elfin remnant
#

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 },
    );
vivid parcel
#

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

elfin remnant
#

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});
vivid parcel
#

Oh you're creating the payment method from the frontend

elfin remnant
#

would I be better off passing the token to the backend and creating from there? Security wise?

vivid parcel
#

What's the reason you're creating the payment method explicitly?

elfin remnant
#

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

teal heathBOT
vivid parcel
#

Oh then directly calling create payment method won't flag the payment method for future use

#

You should be using a setupintent