new to stripe but the documentation looked pretty forward but now stock on something very rudimentary, I can see the customer created in stripe console, same as the product and the price but when I try to attach the payment method retrieved from cardElement, and send it to server i get the message that paymentMethod is not valid. I'm following stripe docs in this page https://stripe.com/docs/billing/subscriptions/fixed-price#create-customer
In javascript i have:
const payload = await stripe.createPaymentMethod({
type: 'card',
card: elements.getElement(CardElement),
billing_details: billingDetails,
});
this comes back with an paymentMethod object with id
paymentMethod.id be like pm_1GoHU32eZvKYloXXXXXXX
on the server side:
await stripe.paymentMethods.attach(paymentMethodId, {
customer: customerId,
});
but i get an exception like below
StripeInvalidRequestError: No such PaymentMethod: pm_1GoHU32eZvKYloXXXXXXX
at Function.generate (/root/coco/node_modules/stripe/lib/Error.js:39:16)
at IncomingMessage.<anonymous>
(/root/coco/node_modules/stripe/lib/StripeResource.js:175:33)
at Object.onceWrapper (events.js:421:28)
at IncomingMessage.emit (events.js:327:22)
at IncomingMessage.EventEmitter.emit (domain.js:485:12)
at endReadableNT (_stream_readable.js:1225:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
type: 'StripeInvalidRequestError',
raw: {
code: 'resource_missing',
doc_url: 'https://stripe.com/docs/error-codes/resource-missing',
message: 'No such PaymentMethod: pm_1GoHU32eZvKYlo2CYLA3SCaX',