Class: ActiveMerchant::Billing::MerchantPartnersGateway

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

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, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ MerchantPartnersGateway

Returns a new instance of MerchantPartnersGateway.



16
17
18
19
# File 'lib/active_merchant/billing/gateways/merchant_partners.rb', line 16

def initialize(options = {})
  requires!(options, :account_id, :merchant_pin)
  super
end

Instance Method Details

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



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

def authorize(amount, payment_method, options = {})
  post = {}
  add_invoice(post, amount, options)
  add_payment_method(post, payment_method)
  add_customer_data(post, options)

  commit(:authorize, post)
end

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



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

def capture(amount, authorization, options = {})
  post = {}
  add_invoice(post, amount, options)
  add_reference(post, authorization)
  add_customer_data(post, options)

  commit(:capture, post)
end

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



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

def credit(amount, payment_method, options = {})
  post = {}
  add_invoice(post, amount, options)
  add_payment_method(post, payment_method)

  commit(payment_method.is_a?(String) ? :stored_credit : :credit, post)
end

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



21
22
23
24
25
26
27
28
# File 'lib/active_merchant/billing/gateways/merchant_partners.rb', line 21

def purchase(amount, payment_method, options = {})
  post = {}
  add_invoice(post, amount, options)
  add_payment_method(post, payment_method)
  add_customer_data(post, options)

  commit(payment_method.is_a?(String) ? :stored_purchase : :purchase, post)
end

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



55
56
57
58
59
60
61
62
# File 'lib/active_merchant/billing/gateways/merchant_partners.rb', line 55

def refund(amount, authorization, options = {})
  post = {}
  add_invoice(post, amount, options)
  add_reference(post, authorization)
  add_customer_data(post, options)

  commit(:refund, post)
end

#scrub(transcript) ⇒ Object



93
94
95
96
97
98
# File 'lib/active_merchant/billing/gateways/merchant_partners.rb', line 93

def scrub(transcript)
  transcript.
    gsub(%r((<ccnum>)[^<]+(<))i, '\1[FILTERED]\2').
    gsub(%r((<cvv2>)[^<]+(<))i, '\1[FILTERED]\2').
    gsub(%r((<merchantpin>)[^<]+(<))i, '\1[FILTERED]\2')
end

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



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

def store(payment_method, options = {})
  post = {}
  add_payment_method(post, payment_method)
  add_customer_data(post, options)

  post[:profileactiontype] = options[:profileactiontype] || STORE_TX_TYPES[:store_only]

  commit(:store, post)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/active_merchant/billing/gateways/merchant_partners.rb', line 89

def supports_scrubbing?
  true
end

#test?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/active_merchant/billing/gateways/merchant_partners.rb', line 100

def test?
  @options[:account_id].eql?('TEST0')
end

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



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

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



48
49
50
51
52
53
# File 'lib/active_merchant/billing/gateways/merchant_partners.rb', line 48

def void(authorization, options = {})
  post = {}
  add_reference(post, authorization)

  commit(:void, post)
end