Sha256: 8162ecce0f0d23db67f7cc553b9738601b0afa348efac0f90f2cd909ec67fc66

Contents?: true

Size: 938 Bytes

Versions: 2

Compression:

Stored size: 938 Bytes

Contents

require 'spree_core'
require 'signifyd'
require 'spree_signifyd/create_signifyd_case'
require 'spree_signifyd/engine'
require 'spree_signifyd/request_verifier'
require 'resque'
require 'devise'

module SpreeSignifyd

  module_function

  def set_score(order:, score:)
    if order.signifyd_order_score
      order.signifyd_order_score.update!(score: score)
    else
      order.create_signifyd_order_score!(score: score)
    end
  end

  def approve(order:)
    order.contents.approve(name: self.name)
    order.shipments.each { |shipment| shipment.ready! unless shipment.ready? }
    order.updater.update_shipment_state
    order.save!
  end

  def create_case(order_number:)
    Rails.logger.info "Queuing Signifyd case creation event: #{order_number}"
    Resque.enqueue(SpreeSignifyd::CreateSignifydCase, order_number)
  end

  def score_above_threshold?(score)
    score > SpreeSignifyd::Config[:signifyd_score_threshold]
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_signifyd-1.0.0 lib/spree_signifyd.rb
solidus_signifyd-0.1.1 lib/spree_signifyd.rb