FIX: 500 error when editing a pricing plan (#94)

`.dig` isn't valid for stripe objects. This commit fixes this 500 error
you get when trying to edit a pricing plan:

```
NoMethodError (undefined method `dig' for #<Stripe::Price:0x....)
```
This commit is contained in:
Blake Erickson 2021-11-12 16:20:16 -07:00 committed by GitHub
parent e8621cf5d1
commit 4f2af3b01a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -55,7 +55,10 @@ module DiscourseSubscriptions
trial_days = plan[:recurring][:trial_period_days]
end
interval = plan.dig(:recurring, :interval)
interval = nil
if plan[:recurring] && plan[:recurring][:interval]
interval = plan[:recurring][:interval]
end
serialized = plan.to_h.merge(trial_period_days: trial_days, currency: plan[:currency].upcase, interval: interval)