From cf84aefb3cd315229da443304144ec7a8a9c5aed Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 30 Jun 2021 21:39:41 -0500 Subject: [PATCH] Handle invalid customer id An invalid customer id is an error from braintree, so handle the error and return an empty list of payment methods. --- lib/customer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/customer.rb b/lib/customer.rb index 55bff1e..48dc8b1 100644 --- a/lib/customer.rb +++ b/lib/customer.rb @@ -60,8 +60,7 @@ class Customer ) @plan = CustomerPlan.new( customer_id, - plan: plan_name && Plan.for(plan_name), - expires_at: expires_at + plan: plan_name && Plan.for(plan_name), expires_at: expires_at ) @usage = CustomerUsage.new(customer_id) @customer_id = customer_id @@ -82,6 +81,7 @@ class Customer BRAINTREE .customer .find(@customer_id) + .catch { OpenStruct.new(payment_methods: []) } .then(PaymentMethods.method(:for_braintree_customer)) end -- 2.38.5