Class: ActiveMerchant::Billing::MerchantWarriorGateway

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

Constant Summary collapse

TOKEN_TEST_URL =
'https://base.merchantwarrior.com/token/'
TOKEN_LIVE_URL =
'https://api.merchantwarrior.com/token/'
POST_TEST_URL =
'https://base.merchantwarrior.com/post/'
POST_LIVE_URL =
'https://api.merchantwarrior.com/post/'

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 = {}) ⇒ MerchantWarriorGateway

Returns a new instance of MerchantWarriorGateway.



22
23
24
25
# File 'lib/active_merchant/billing/gateways/merchant_warrior.rb', line 22

def initialize(options = {})
  requires!(options, :merchant_uuid, :api_key, :api_passphrase)
  super
end

Instance Method Details

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



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/active_merchant/billing/gateways/merchant_warrior.rb', line 27

def authorize(money, payment_method, options = {})
  post = {}
  add_amount(post, money, options)
  add_order_id(post, options)
  add_address(post, options)
  add_payment_method(post, payment_method)
  add_recurring_flag(post, options)
  add_soft_descriptors(post, options)
  add_three_ds(post, options)
  post['storeID'] = options[:store_id] if options[:store_id]
  commit('processAuth', post)
end

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



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

def capture(money, identification, options = {})
  post = {}
  add_amount(post, money, options)
  add_transaction(post, identification)
  add_soft_descriptors(post, options)
  post['captureAmount'] = amount(money)
  commit('processCapture', post)
end

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



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

def purchase(money, payment_method, options = {})
  post = {}
  add_amount(post, money, options)
  add_order_id(post, options)
  add_address(post, options)
  add_payment_method(post, payment_method)
  add_recurring_flag(post, options)
  add_soft_descriptors(post, options)
  add_three_ds(post, options)
  post['storeID'] = options[:store_id] if options[:store_id]
  commit('processCard', post)
end

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



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

def refund(money, identification, options = {})
  post = {}
  add_amount(post, money, options)
  add_transaction(post, identification)
  add_soft_descriptors(post, options)
  post['refundAmount'] = amount(money)
  commit('refundCard', post)
end

#scrub(transcript) ⇒ Object



95
96
97
98
99
100
101
# File 'lib/active_merchant/billing/gateways/merchant_warrior.rb', line 95

def scrub(transcript)
  transcript.
    gsub(%r((&?paymentCardNumber=)[^&]*)i, '\1[FILTERED]').
    gsub(%r((CardNumber=)[^&]*)i, '\1[FILTERED]').
    gsub(%r((&?paymentCardCSC=)[^&]*)i, '\1[FILTERED]').
    gsub(%r((&?apiKey=)[^&]*)i, '\1[FILTERED]')
end

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



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

def store(creditcard, options = {})
  post = {
    'cardName' => scrub_name(creditcard.name),
    'cardNumber' => creditcard.number,
    'cardExpiryMonth' => format(creditcard.month, :two_digits),
    'cardExpiryYear'  => format(creditcard.year, :two_digits)
  }
  commit('addCard', post)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/active_merchant/billing/gateways/merchant_warrior.rb', line 91

def supports_scrubbing?
  true
end

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



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

def void(identification, options = {})
  post = {}
  # The amount parameter is required for void transactions
  # on the Merchant Warrior gateway.
  post['transactionAmount'] = options[:amount]
  post['hash'] = void_verification_hash(identification)
  add_transaction(post, identification)
  commit('processVoid', post)
end