Handle invalid customer id

Stephen Paul Weber created

An invalid customer id is an error from braintree, so handle the error and
return an empty list of payment methods.

Change summary

lib/customer.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Detailed changes

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