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::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#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

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

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



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

def capture(money, identification, options = {})
  post = {}
  add_amount(post, money, options)
  add_transaction(post, identification)
  post.merge!('captureAmount' => amount(money))
  commit('processCapture', post)
end

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



36
37
38
39
40
41
42
43
# File 'lib/active_merchant/billing/gateways/merchant_warrior.rb', line 36

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

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



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

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

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



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

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