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

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
# 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)
  commit('processAuth', post)
end

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



49
50
51
52
53
54
55
56
# File 'lib/active_merchant/billing/gateways/merchant_warrior.rb', line 49

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



38
39
40
41
42
43
44
45
46
47
# File 'lib/active_merchant/billing/gateways/merchant_warrior.rb', line 38

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)
  commit('processCard', post)
end

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



58
59
60
61
62
63
64
65
# File 'lib/active_merchant/billing/gateways/merchant_warrior.rb', line 58

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



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

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



77
78
79
80
81
82
83
84
85
# File 'lib/active_merchant/billing/gateways/merchant_warrior.rb', line 77

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)


87
88
89
# File 'lib/active_merchant/billing/gateways/merchant_warrior.rb', line 87

def supports_scrubbing?
  true
end

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



67
68
69
70
71
72
73
74
75
# File 'lib/active_merchant/billing/gateways/merchant_warrior.rb', line 67

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