Sha256: b3e0a905c02798f2f4c6f7ad93297f0032e4a2addb82030ce84c9659212c569d

Contents?: true

Size: 1.3 KB

Versions: 15

Compression:

Stored size: 1.3 KB

Contents

class OrderPayment < ActiveRecord::Base
 
  belongs_to :order
  belongs_to :user

  attr_accessor :sage_pay_results

  def self.load_from_sage_pay_response(system_id, crypt)
    results = {}
    dec = Order.sage_decrypt(system_id, crypt.gsub(' ', '+'))
    dec.split('&').each do |vv|
      n,v = vv.split('=')
      results[n] = v
    end
    ref = results["VendorTxCode"].split('-')
    order_id = ref[1]
    payment_id = ref[3]

    op = OrderPayment.sys(system_id).where(:id=>payment_id).first
    
    return nil if op.order_id.to_s != order_id.to_s

    op.sage_pay_results = results 
    return op
  end

  def update_from_sage_pay_results
    self.status = self.sage_pay_results["StatusDetail"]
    self.address_status = self.sage_pay_results["AddressResult"]
    self.postcode_status = self.sage_pay_results["PostCodeResult"]
    self.cv2_status = self.sage_pay_results["CV2Result"]
    self.threed_secure_status = self.sage_pay_results["3DSecureStatus"]
    self.card_identifier = self.sage_pay_results["Last4Digits"]
    self.card_type = self.sage_pay_results["CardType"]
    self.auth_code = self.sage_pay_results["TxAuthNo"]
    self.tx_id = self.sage_pay_results["VPSTxId"]
    self.processed_at = Time.now
    self.save

    self.order.status = self.sage_pay_results["Status"]
    self.order.save
  end

  
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
kit_cms-2.3.22 app/models/order_payment.rb
kit_cms-2.3.20 app/models/order_payment.rb
kit_cms-2.3.19 app/models/order_payment.rb
kit_cms-2.3.18 app/models/order_payment.rb
kit_cms-2.3.17 app/models/order_payment.rb
kit_cms-2.3.16 app/models/order_payment.rb
kit_cms-2.3.15 app/models/order_payment.rb
kit_cms-2.3.14 app/models/order_payment.rb
kit_cms-2.3.13 app/models/order_payment.rb
kit_cms-2.3.11 app/models/order_payment.rb
kit_cms-2.3.10 app/models/order_payment.rb
kit_cms-2.3.9 app/models/order_payment.rb
kit_cms-2.3.8 app/models/order_payment.rb
kit_cms-2.3.7 app/models/order_payment.rb
kit_cms-2.3.6 app/models/order_payment.rb