Mike Mike - 2 years ago 83
Ruby Question

Stripe API throwing error when trying to delete a card

I'm trying to delete a card from Stripe using the ruby library but I am running in to the following error.

undefined method `delete' for Stripe::Customer:Class

Here is the line in my code that is causing the error

customer = Stripe::Customer.delete(@user.stripe_id)

There doesn't seem to be a delete method on the Customer class but the docs say there is.

Here is the section of the Stripe documentation that deals with deleting cards.

As you can see my code is identical to the line in the docs other than where the customer id is coming from.

Also, I did notice an error in the documentation in which,

customer = Stripe::Customer.delete({CARD_ID})

Should be,

customer = Stripe::Customer.delete({CUSTOMER_ID})

I've tried using the card id as well just to be sure and it generates the same error.

If anyone has any ideas, they would be greatly appreciated.

EDIT: I have been using stripe up until this point just fine with other methods such as
working just fine.

EDIT 2: I'm using gem version 1.8.4 which seems to be the latest release.

Answer Source

There seem to be two errors in the docs, have you tried this instead:

customer = Stripe::Customer.retrieve({CUSTOMER_ID})
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download