Sha256: bfaad6b9be7ca3f6077b77d24136615a00bee0f7b1f8ca226cd0caea9f3c1e42
Contents?: true
Size: 1.38 KB
Versions: 8
Compression:
Stored size: 1.38 KB
Contents
module Spreedly class Transaction < Model field :state, :message field :succeeded, type: :boolean def self.new_from(xml_doc) case xml_doc.at_xpath('.//transaction_type').inner_text when 'AddPaymentMethod' return AddPaymentMethod.new(xml_doc) when 'Purchase' return Purchase.new(xml_doc) when 'OffsitePurchase' return OffsitePurchase.new(xml_doc) when 'Authorization' return Authorization.new(xml_doc) when 'Capture' return Capture.new(xml_doc) when 'Credit' return Refund.new(xml_doc) when 'Void' return Void.new(xml_doc) when 'Verification' return Verification.new(xml_doc) when 'RetainPaymentMethod' return RetainPaymentMethod.new(xml_doc) when 'RedactPaymentMethod' return RedactPaymentMethod.new(xml_doc) when 'RedactGateway' return RedactGateway.new(xml_doc) when 'RecacheSensitiveData' return RecacheSensitiveData.new(xml_doc) when 'DeliverPaymentMethod' return DeliverPaymentMethod.new(xml_doc) when 'Store' return Store.new(xml_doc) else Transaction.new(xml_doc) end end def self.new_list_from(xml_doc) transactions = xml_doc.xpath('.//transactions/transaction') transactions.map do |each| self.new_from(each) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems