Class: Spree::TaxIdentifierValidationSubscriber
- Inherits:
-
Subscriber
- Object
- Subscriber
- Spree::TaxIdentifierValidationSubscriber
- Defined in:
- app/subscribers/spree/tax_identifier_validation_subscriber.rb
Overview
Asks the registry whether a buyer's tax number is real, whenever that number changes.
Runs synchronously: the row has to read pending in the same request that
wrote it, so the buyer sees "we're checking this" rather than a blank verdict
that fills in later. The check itself is the background job.
Instance Method Summary collapse
Instance Method Details
#call(event) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/subscribers/spree/tax_identifier_validation_subscriber.rb', line 13 def call(event) identifier = Spree::TaxIdentifier.find_by_prefix_id(event.payload['id']) return if identifier.nil? # Nothing to ask when no validator is registered for this kind — a stock # install registers none — and an order's snapshot is never re-checked. return unless identifier.validatable? # The row is already marked pending by the write that published this; # queueing the registry call is all that is left. Spree::TaxIdentifiers::ValidateJob.perform_later(identifier.id) end |