Class: ActiveMerchant::Billing::CommerceHubGateway

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

Constant Summary collapse

STANDARD_ERROR_CODE_MAPPING =
{}
SCHEDULED_REASON_TYPES =
%w(recurring installment)
ENDPOINTS =
{
  'sale' => '/payments/v1/charges',
  'void' => '/payments/v1/cancels',
  'refund' => '/payments/v1/refunds',
  'vault' => '/payments-vas/v1/tokens',
  'verify' => '/payments-vas/v1/accounts/verification'
}

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, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #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 = {}) ⇒ CommerceHubGateway

Returns a new instance of CommerceHubGateway.



25
26
27
28
# File 'lib/active_merchant/billing/gateways/commerce_hub.rb', line 25

def initialize(options = {})
  requires!(options, :api_key, :api_secret, :merchant_id, :terminal_id)
  super
end

Instance Method Details

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



41
42
43
44
45
46
47
48
49
50
# File 'lib/active_merchant/billing/gateways/commerce_hub.rb', line 41

def authorize(money, payment, options = {})
  post = {}
  options[:capture_flag] = false
  options[:create_token] = false

  add_transaction_details(post, options, 'sale')
  build_purchase_and_auth_request(post, money, payment, options)

  commit('sale', post, options)
end

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



52
53
54
55
56
57
58
59
60
61
# File 'lib/active_merchant/billing/gateways/commerce_hub.rb', line 52

def capture(money, authorization, options = {})
  post = {}
  options[:capture_flag] = true
  add_invoice(post, money, options)
  add_transaction_details(post, options, 'capture')
  add_reference_transaction_details(post, authorization, options, :capture)
  add_dynamic_descriptors(post, options)

  commit('sale', post, options)
end

#credit(money, payment_method, options = {}) ⇒ Object



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

def credit(money, payment_method, options = {})
  post = {}
  add_invoice(post, money, options)
  add_transaction_interaction(post, options)
  add_payment(post, payment_method, options)

  commit('refund', post, options)
end

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



30
31
32
33
34
35
36
37
38
39
# File 'lib/active_merchant/billing/gateways/commerce_hub.rb', line 30

def purchase(money, payment, options = {})
  post = {}
  options[:capture_flag] = true
  options[:create_token] = false

  add_transaction_details(post, options, 'sale')
  build_purchase_and_auth_request(post, money, payment, options)

  commit('sale', post, options)
end

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



63
64
65
66
67
68
69
70
# File 'lib/active_merchant/billing/gateways/commerce_hub.rb', line 63

def refund(money, authorization, options = {})
  post = {}
  add_invoice(post, money, options) if money
  add_transaction_details(post, options)
  add_reference_transaction_details(post, authorization, options, :refund)

  commit('refund', post, options)
end

#scrub(transcript) ⇒ Object



111
112
113
114
115
116
117
118
119
# File 'lib/active_merchant/billing/gateways/commerce_hub.rb', line 111

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: )[a-zA-Z0-9+./=]+), '\1[FILTERED]').
    gsub(%r((Api-Key: )\w+), '\1[FILTERED]').
    gsub(%r(("apiKey\\?":\\?")\w+), '\1[FILTERED]').
    gsub(%r(("cardData\\?":\\?")\d+), '\1[FILTERED]').
    gsub(%r(("securityCode\\?":\\?")\d+), '\1[FILTERED]').
    gsub(%r(("cavv\\?":\\?")\w+), '\1[FILTERED]')
end

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



89
90
91
92
93
94
95
96
97
# File 'lib/active_merchant/billing/gateways/commerce_hub.rb', line 89

def store(credit_card, options = {})
  post = {}
  add_payment(post, credit_card, options)
  add_billing_address(post, credit_card, options)
  add_transaction_details(post, options)
  add_transaction_interaction(post, options)

  commit('vault', post, options)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/active_merchant/billing/gateways/commerce_hub.rb', line 107

def supports_scrubbing?
  true
end

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



99
100
101
102
103
104
105
# File 'lib/active_merchant/billing/gateways/commerce_hub.rb', line 99

def verify(credit_card, options = {})
  post = {}
  add_payment(post, credit_card, options)
  add_billing_address(post, credit_card, options)

  commit('verify', post, options)
end

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



81
82
83
84
85
86
87
# File 'lib/active_merchant/billing/gateways/commerce_hub.rb', line 81

def void(authorization, options = {})
  post = {}
  add_transaction_details(post, options)
  add_reference_transaction_details(post, authorization, options, :void)

  commit('void', post, options)
end