Class: ActiveMerchant::Billing::TransactProGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/transact_pro.rb

Overview

For more information visit Transact Pro Services

This gateway was formerly associated with www.1stpayments.net

Written by Piers Chambers (Varyonic.com)

Constant Summary

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #scrub, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #test?

Methods included from CreditCardFormatting

#expdate, #format, #strftime_yyyymm

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ TransactProGateway

Returns a new instance of TransactProGateway.



20
21
22
23
# File 'lib/active_merchant/billing/gateways/transact_pro.rb', line 20

def initialize(options = {})
  requires!(options, :guid, :password, :terminal)
  super
end

Instance Method Details

#authorize(amount, payment, options = {}) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/active_merchant/billing/gateways/transact_pro.rb', line 47

def authorize(amount, payment, options = {})
  post = PostData.new
  add_invoice(post, amount, options)
  add_payment(post, payment)
  add_address(post, payment, options)
  add_customer_data(post, options)
  add_credentials(post)
  post[:rs] = @options[:terminal]

  MultiResponse.run do |r|
    r.process { commit('init_dms', post) }
    r.process do
      post = PostData.new
      post[:init_transaction_id] = r.authorization
      add_payment_cc(post, payment)
      post[:f_extended] = '4'

      commit('make_hold', post, amount)
    end
  end
end

#capture(amount, authorization, options = {}) ⇒ Object

Raises:

  • (ArgumentError)


69
70
71
72
73
74
75
76
77
78
79
# File 'lib/active_merchant/billing/gateways/transact_pro.rb', line 69

def capture(amount, authorization, options = {})
  identifier, original_amount = split_authorization(authorization)
  raise ArgumentError.new("Partial capture is not supported, and #{amount.inspect} != #{original_amount.inspect}") if amount && (amount != original_amount)

  post = PostData.new
  add_credentials(post)
  post[:init_transaction_id] = identifier
  post[:f_extended] = '4'

  commit('charge_hold', post, original_amount)
end

#purchase(amount, payment, options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/active_merchant/billing/gateways/transact_pro.rb', line 25

def purchase(amount, payment, options = {})
  post = PostData.new
  add_invoice(post, amount, options)
  add_payment(post, payment)
  add_address(post, payment, options)
  add_customer_data(post, options)
  add_credentials(post)
  post[:rs] = @options[:terminal]

  MultiResponse.run do |r|
    r.process { commit('init', post) }
    r.process do
      post = PostData.new
      post[:init_transaction_id] = r.authorization
      add_payment_cc(post, payment)
      post[:f_extended] = '4'

      commit('charge', post, amount)
    end
  end
end

#refund(amount, authorization, options = {}) ⇒ Object



81
82
83
84
85
86
87
88
89
90
# File 'lib/active_merchant/billing/gateways/transact_pro.rb', line 81

def refund(amount, authorization, options = {})
  identifier, original_amount = split_authorization(authorization)

  post = PostData.new
  add_credentials(post, :account_guid)
  post[:init_transaction_id] = identifier
  post[:amount_to_refund] = amount(amount || original_amount)

  commit('refund', post)
end

#verify(credit_card, options = {}) ⇒ Object



102
103
104
105
106
107
# File 'lib/active_merchant/billing/gateways/transact_pro.rb', line 102

def verify(credit_card, options = {})
  MultiResponse.run(:use_first_response) do |r|
    r.process { authorize(100, credit_card, options) }
    r.process(:ignore_result) { void(r.authorization, options) }
  end
end

#void(authorization, options = {}) ⇒ Object



92
93
94
95
96
97
98
99
100
# File 'lib/active_merchant/billing/gateways/transact_pro.rb', line 92

def void(authorization, options = {})
  identifier, amount = split_authorization(authorization)

  post = PostData.new
  add_credentials(post, :account_guid)
  post[:init_transaction_id] = identifier
  post[:amount_to_refund] = amount(amount)
  commit('cancel_dms', post)
end