Sha256: 06e3fc992ff36d891e97d3ad6714930760a64bde4ce0685ecb5fc1de544236a9

Contents?: true

Size: 1.73 KB

Versions: 2

Compression:

Stored size: 1.73 KB

Contents

module AbtainBilling #:nodoc:
  module Billing #:nodoc:
    module Integrations #:nodoc:
      module HiTrust
        class Helper < AbtainBilling::Billing::Integrations::Helper
          
          # Transaction types
          # * Auth
          # * AuthRe
          # * Capture
          # * CaptureRe
          # * Refund
          # * RefundRe
          # * Query
          def initialize(order, account, options = {})
            super  
            # Perform an authorization by default
            add_field('Type', 'Auth')
            
            # Capture the payment right away
            add_field('depositflag', '1')
            
            # Disable auto query - who knows what it does?
            add_field('queryflag', '1')
            
            add_field('orderdesc', 'Store purchase')
          end
          
          mapping :account, 'storeid'
          mapping :amount, 'amount'
          
          def amount=(money)
            cents = money.respond_to?(:cents) ? money.cents : money 

            if money.is_a?(String) or cents.to_i < 0
              raise ArgumentError, 'money amount must be either a Money object or a positive integer in cents.' 
            end
            
            add_field(mappings[:amount], cents)
          end
          # Supported currencies include:
          # * CNY:Chinese Yuan (Renminbi)
          # * TWD:New Taiwan Dollar 
          # * HKD:Hong Kong Dollar 
          # * USD:US Dollar 
          # * AUD:Austrian Dollar 
          mapping :currency, 'currency'
        
          mapping :order, 'ordernumber'
          mapping :description, 'orderdesc'

          mapping :notify_url, 'merUpdateURL'
          mapping :return_url, 'returnURL'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
abtain_billing-1.03 lib/abtain_billing/billing/integrations/hi_trust/helper.rb
abtain_billing-1.02 lib/abtain_billing/billing/integrations/hi_trust/helper.rb