#RMoura_JS-paymentmethods

1 messages · Page 1 of 1 (latest)

heady hamlet
edgy lagoon
#

pm_1Js85qIGDBqjniobuxwEjzDR

#

sadly I have no access to the stripe account...

prime mulch
#

Thanks for the ID

#

To which Stripe account?

edgy lagoon
prime mulch
#

Ah, thanks for clarifying

edgy lagoon
#

does doing this fix the proble?

#
            payment_method_id,
            { customer: retrieve_customer.id }
          )```
prime mulch
#

It could

#

As the error message said this may also have been detached which would mean it may not be used again. Having trouble finding it if it was

#

Try attaching and see what happens

#

Otherwise this is a test PM you can create it again and attach

edgy lagoon
#

ok! ill try it, ill update you in a bit

prime mulch
#

Thank you!

edgy lagoon
#

*** Stripe::InvalidRequestError Exception: This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again.

#

when i try to attach it

#

im getting the pm id from a Stripe::PaymentIntent.retrieve(intent_id)

prime mulch
#

Ah so it needs to be attached before being used.

#

How are you creating it?

edgy lagoon
#

hmmm

#

using a stripe element

#

customer = retrieve_customer

      ::Stripe::PaymentIntent.create(
        amount: prepare_amount(amount),
        currency: amount.currency.to_s,
        payment_method_types: payment_types,
        description: description,
        capture_method: 'automatic',
        customer: customer&.id,
        metadata: metadata
        # setup_future_usage: 'off_session'
      )
#

and then creating a stripe payment element with the payment intent id

prime mulch
edgy lagoon
#

customer: customer&.id, here? no?

prime mulch
#

I am unfamiliar with the &. operator. Is that something that won't pass anything/will pass in null if customer is null?

edgy lagoon
#

ahhh

#

interesting

#

yes

#

its possible

#

pi_3JttRNIGDBqjniob0AwCuBbX

#

cus_JJS3aM0Bkrzmlh

#

"payment_method": "pm_1JttRiIGDBqjniobHAaaMZlU",

#

Stripe::InvalidRequestError - This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again.

#

i think the setup_future_usage is needed

#

off_session

prime mulch
edgy lagoon
#

strange

#

because when i create the payment intent it clearly shows the customer

prime mulch
#

But yes, definitely use setup_future_usage as well

edgy lagoon
#

ill try again with that flag

#

trying with this one now: pi_3JttWvIGDBqjniob177ZVJMv

#

I think it works now

#

😮

prime mulch
#

Nice!

#

I do see the customer ID on that creation request