2013-07-23 37 views
2

我試圖從條紋中使用ruby庫刪除一張卡,但我遇到了以下錯誤。試圖刪除卡時條紋API拋出錯誤

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

這裏是我的代碼導致錯誤

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

似乎有不被Customer類的刪除方法行但該文檔說有。

以下是處理刪除卡片的Stripe文檔部分。 https://stripe.com/docs/api/ruby#delete_card

正如您所看到的,我的代碼與文檔中除了客戶ID來自哪裏的行相同。

而且,我也使用該卡的ID以及注意文檔中的錯誤,其中,

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

應該是,

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

我試過只是要確定它生成相同的錯誤。

如果有人有任何想法,他們將不勝感激。

編輯:我一直在使用條狀直到這一點,還是跟其他的方法,如Stripe::Customer.retrieve()工作得很好很好。

編輯2:我使用的寶石版本1.8.4似乎是最新的版本。

+0

呀,條紋仍然沒有讓顧客[刪除其身份證號碼(HTTPS://support.stripe .COM /問題/可-I-刪除-A-客戶-S卡從 - 我的條紋賬戶),我認爲這是不可接受的。 –

+0

其實這是可能的,看到這個[博客文章(https://stripe.com/blog/multiple-cards)和[相關API(https://stripe.com/docs/api#delete_card)。儘管使用Stripe的網站迄今爲止所遇到的網站並不在意實現此功能。 –

回答

7

似乎有要在文檔中的兩個錯誤,你嘗試過這個代替:

customer = Stripe::Customer.retrieve({CUSTOMER_ID}) 
customer.cards.retrieve({CARD_ID}).delete() 
+0

現在應該修復文檔。對於那個很抱歉! – brian

+1

我得到一個'*** NoMethodError例外:未定義的方法 '刪除' 的#<條紋::的ListObject:0x007fb62e33afb8>'試圖刪除卡 – davidtingsu

+1

修復時:'卡= customer.cards.retrieve({} card_id的) '; 'card.delete' – davidtingsu