0
給定以下方法如何避免訂閱與Stripe不同步?
def change_plan_to(plan_id)
new_plan = Plan.find plan_id
stripe_customer = Stripe::Customer.retrieve(stripe_customer_token)
stripe_customer.update_subscription(plan: new_plan.slug)
self.plan = new_plan
self.active = true
save
rescue Stripe::InvalidRequestError => e
logger.error "[STRIPE] #{ e }"
errors.add :base, "Unable to change your plan!"
false
end
具體地說線#4-6。我希望4和5只在4成功時纔會發生,但Stripe不會返回將它包裝在if中的能力。如果它錯誤,它只會引發Stripe :: InvalidRequestError。
處理這個問題的最佳方法是什麼?火&忘記並允許條紋webhook回調管理到期的活動狀態根據需要?
另一種情況是,如果沒有通過,所有代碼將在第4行之後停止。這是如何營救的?
您在開發過程中如何做到這一點? Stripe不能發送回調到本地開發url? –
使用http://progrium.com/localtunnel/將您的本地主機url映射到公開網址。 –
添加然後添加此網址條紋webhooks網址.. –