~singpolyma/sgx-jmp

cf84aefb3cd315229da443304144ec7a8a9c5aed — Stephen Paul Weber 3 years ago bbc0bb6
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.
1 files changed, 2 insertions(+), 2 deletions(-)

M lib/customer.rb
M lib/customer.rb => lib/customer.rb +2 -2
@@ 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