Skip to content

Commit

Permalink
mollie_customer_id could not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanlieshout committed Aug 10, 2020
1 parent fde5616 commit 78a7fc1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/models/spree/user_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ def self.prepended(base)
base.after_commit :ensure_mollie_customer, on: %i[create update]
end


def ensure_mollie_customer
return if mollie_customer_id&.present?

# Don't create Mollie customers if spree_auth_devise is not installed.
return unless defined? Spree::User

mollie_gateway = Spree::PaymentMethod.find_by_type 'Spree::Gateway::MollieGateway'
return unless mollie_gateway&.active?

return if mollie_customer_id.present?

mollie_customer = mollie_gateway.create_customer(self)
update mollie_customer_id: mollie_customer.id
end
Expand Down

0 comments on commit 78a7fc1

Please sign in to comment.