From 2a616125c199736d339c6dad08496e08596abaeb Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 16 Jun 2021 10:33:52 +0200 Subject: [PATCH] [bug] unable to sync users on stripe if one of them have an invalid email address --- CHANGELOG.md | 1 + app/workers/sync_objects_on_stripe_worker.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5606bc5ce..efa7e8593 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog Fab-manager - Fix a bug: during the upgrade, unable to detect the target when not explicitly specified +- Fix a bug: unable to sync users on stripe if one of them have an invalid email address ## v5.0.4 2021 June 15 diff --git a/app/workers/sync_objects_on_stripe_worker.rb b/app/workers/sync_objects_on_stripe_worker.rb index 63eb29f1d..4add9fbef 100644 --- a/app/workers/sync_objects_on_stripe_worker.rb +++ b/app/workers/sync_objects_on_stripe_worker.rb @@ -11,10 +11,14 @@ class SyncObjectsOnStripeWorker User.online_payers.each_with_index do |member, index| logger.debug "#{index} / #{total}" begin - stp_customer = member.payment_gateway_object.gateway_object.retrieve + stp_customer = member.payment_gateway_object&.gateway_object&.retrieve StripeWorker.new.create_stripe_customer(member.id) if stp_customer.nil? || stp_customer[:deleted] rescue Stripe::InvalidRequestError - StripeWorker.new.create_stripe_customer(member.id) + begin + StripeWorker.new.create_stripe_customer(member.id) + rescue Stripe::InvalidRequestError => e + puts "Unable to create the customer #{member.id} do to a Stripe error: #{e}" + end end end