无法使用 Stripe 保存或取消订阅 [英] unable to save or cancel subscriptions using Stripe

查看:67
本文介绍了无法使用 Stripe 保存或取消订阅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Ruby on Rails 中使用 stripe 的 API 我无法保存订阅.

Using stripe's API with Ruby on Rails I am unable to save subscriptions.

我能够检索、更新和保存客户对象:

I am able to retrieve and update and save customer objects:

customer = Stripe::Customer.retrieve(some_customer_id) #this works
customer.save #this works

我还可以检索订阅:subscription=customer.subscriptions.retrieve("some_subscription_id") #这个有效

I am also able to retrieve subscriptions: subscription=customer.subscriptions.retrieve("some_subscription_id") #this works

但是,在尝试保存订阅时:subscription.save #this 不起作用

However, when trying to save a subscription: subscription.save #this doesn't work

我一直收到这个:

NoMethodError: undefined method `save' for 
#<Stripe::StripeObject:0x007ff37147c720>
from /Users/me/.rvm/gems/ruby-2.0.0-p353/gems/stripe-    
1.9.9/lib/stripe/stripe_object.rb:158:in `method_missing'

尝试取消订阅时类似:

customer.subscriptions.retrieve("sub_3QM09lOz64QuSf").delete()

我明白了:

NoMethodError: undefined method `delete' for 
    #<Stripe::StripeObject:0x007ff36d3f0d50>
from /Users/me/.rvm/gems/ruby-2.0.0-p353/gems/stripe-
    1.9.9/lib/stripe/stripe_object.rb:158:in `method_missing'

没有这个,我就不能让客户直接从网站取消.

Without this I am not able to allow customers to cancel directly from the site.

我错过了什么?

推荐答案

使用 bundle update stripe 升级到他们最新的 gem,然后重试.订阅在 1.10.0 左右的某个时候发生了变化,需要一个版本来保存它们.通过将您的 gemfile 配置为使用他们的 github 存储库,您实际上是在使用捆绑包时可用的最新版本.

Upgrade to their latest gem with bundle update stripe and try again. Subscriptions were changed sometime around 1.10.0 and requires a version after that to save them. By configuring your gemfile to use their github repository you're essentially using the latest version available at the time of your bundle.

这篇关于无法使用 Stripe 保存或取消订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆