lib/active_merchant/billing/gateways/wirecard.rb in activemerchant-1.29.3 vs lib/active_merchant/billing/gateways/wirecard.rb in activemerchant-1.30.0

- old
+ new

@@ -14,11 +14,11 @@ ENVELOPE_NAMESPACES = { 'xmlns:xsi' => 'http://www.w3.org/1999/XMLSchema-instance', 'xsi:noNamespaceSchemaLocation' => 'wirecard.xsd' } - PERMITTED_TRANSACTIONS = %w[ AUTHORIZATION CAPTURE_AUTHORIZATION PURCHASE ] + PERMITTED_TRANSACTIONS = %w[ PREAUTHORIZATION CAPTURE PURCHASE ] RETURN_CODES = %w[ ACK NOK ] # Wirecard only allows phone numbers with a format like this: +xxx(yyy)zzz-zzzz-ppp, where: # xxx = Country code @@ -61,17 +61,17 @@ end # Authorization def authorize(money, creditcard, options = {}) options[:credit_card] = creditcard - commit(:authorization, money, options) + commit(:preauthorization, money, options) end # Capture Authorization def capture(money, authorization, options = {}) - options[:authorization] = authorization - commit(:capture_authorization, money, options) + options[:preauthorization] = authorization + commit(:capture, money, options) end # Purchase def purchase(money, creditcard, options = {}) options[:credit_card] = creditcard @@ -146,32 +146,38 @@ # Includes the whole transaction data (payment, creditcard, address) def add_transaction_data(xml, money, options) options[:order_id] ||= generate_unique_id xml.tag! "FNC_CC_#{options[:action].to_s.upcase}" do - xml.tag! 'FunctionID', options[:description] + xml.tag! 'FunctionID', options[:description].to_s.slice(0,32) xml.tag! 'CC_TRANSACTION' do xml.tag! 'TransactionID', options[:order_id] case options[:action] - when :authorization, :purchase + when :preauthorization, :purchase add_invoice(xml, money, options) add_creditcard(xml, options[:credit_card]) add_address(xml, options[:billing_address]) - when :capture_authorization - xml.tag! 'GuWID', options[:authorization] + when :capture + xml.tag! 'GuWID', options[:preauthorization] + add_amount(xml, money) end end end end # Includes the payment (amount, currency, country) to the transaction-xml def add_invoice(xml, money, options) - xml.tag! 'Amount', amount(money) + add_amount(xml, money) xml.tag! 'Currency', options[:currency] || currency(money) xml.tag! 'CountryCode', options[:billing_address][:country] xml.tag! 'RECURRING_TRANSACTION' do xml.tag! 'Type', options[:recurring] || 'Single' end + end + + # Include the amount in the transaction-xml + def add_amount(xml, money) + xml.tag! 'Amount', amount(money) end # Includes the credit-card data to the transaction-xml def add_creditcard(xml, creditcard) raise "Creditcard must be supplied!" if creditcard.nil?