Class: FlowcommerceSpree::Webhooks::FraudStatusChanged
- Inherits:
-
Object
- Object
- FlowcommerceSpree::Webhooks::FraudStatusChanged
- Defined in:
- app/services/flowcommerce_spree/webhooks/fraud_status_changed.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
(also: #full_messages)
Returns the value of attribute errors.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data, opts = {}) ⇒ FraudStatusChanged
constructor
A new instance of FraudStatusChanged.
- #process ⇒ Object
Constructor Details
#initialize(data, opts = {}) ⇒ FraudStatusChanged
Returns a new instance of FraudStatusChanged.
13 14 15 16 17 |
# File 'app/services/flowcommerce_spree/webhooks/fraud_status_changed.rb', line 13 def initialize(data, opts = {}) @data = data @opts = opts @errors = [] end |
Instance Attribute Details
#errors ⇒ Object Also known as: full_messages
Returns the value of attribute errors.
6 7 8 |
# File 'app/services/flowcommerce_spree/webhooks/fraud_status_changed.rb', line 6 def errors @errors end |
Class Method Details
.process(data, opts = {}) ⇒ Object
9 10 11 |
# File 'app/services/flowcommerce_spree/webhooks/fraud_status_changed.rb', line 9 def self.process(data, opts = {}) new(data, opts).process end |
Instance Method Details
#process ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/services/flowcommerce_spree/webhooks/fraud_status_changed.rb', line 19 def process order_number = @data.dig('order', 'number') errors << { message: 'Order number param missing' } && (return self) unless order_number order = Spree::Order.find_by(number: order_number) errors << { message: "Order #{order_number} not found" } && (return self) unless order if @data['status'] == 'declined' order.update_columns(fraudulent: true) order.cancel! end order end |