2

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. https://stripe.com/docs/api/ruby#delete_card

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 Stripe::Customer.retrieve() working just fine.

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

4

1 回答 1

7

文档中似乎有两个错误,您是否尝试过这个:

customer = Stripe::Customer.retrieve({CUSTOMER_ID})
customer.cards.retrieve({CARD_ID}).delete()
于 2013-07-23T11:22:42.283 回答