Class: ActiveMerchant::Billing::VisanetPeruGateway

Inherits:
Gateway
  • Object
show all
Includes:
Empty
Defined in:
lib/active_merchant/billing/gateways/visanet_peru.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?, #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 = {}) ⇒ VisanetPeruGateway

Returns a new instance of VisanetPeruGateway.


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

def initialize(options = {})
  requires!(options, :access_key_id, :secret_access_key, :merchant_id)
  super
end

Instance Method Details

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


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

def authorize(amount, payment_method, options = {})
  params = {}

  add_invoice(params, amount, options)
  add_payment_method(params, payment_method)
  add_antifraud_data(params, options)
  params[:email] = options[:email] || '[email protected]'
  params[:createAlias] = false

  commit('authorize', params, options)
end

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


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

def capture(amount, authorization, options = {})
  params = {}
  options[:id_unico] = split_authorization(authorization)[1]
  add_auth_order_id(params, authorization, options)
  commit('deposit', params, options)
end

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


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

def purchase(amount, payment_method, options = {})
  MultiResponse.run() do |r|
    r.process { authorize(amount, payment_method, options) }
    r.process { capture(amount, r.authorization, options) }
  end
end

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


53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/active_merchant/billing/gateways/visanet_peru.rb', line 53

def refund(amount, authorization, options = {})
  params = {}
  params[:amount] = amount(amount) if amount
  add_auth_order_id(params, authorization, options)
  response = commit('cancelDeposit', params, options)
  return response if response.success? || split_authorization(authorization).length == 1 || !options[:force_full_refund_if_unsettled]

  # Attempt RefundSingleTransaction if unsettled (and stash the original
  # response message so it will be included it in the follow-up response
  # message)
  options[:error_message] = response.message
  prepare_refund_data(params, authorization, options)
  commit('refund', params, options)
end

#scrub(transcript) ⇒ Object


79
80
81
82
83
84
# File 'lib/active_merchant/billing/gateways/visanet_peru.rb', line 79

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r((\"cardNumber\\\":\\\")\d+), '\1[FILTERED]').
    gsub(%r((\"cvv2Code\\\":\\\")\d+), '\1[FILTERED]')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)

75
76
77
# File 'lib/active_merchant/billing/gateways/visanet_peru.rb', line 75

def supports_scrubbing?
  true
end

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


68
69
70
71
72
73
# File 'lib/active_merchant/billing/gateways/visanet_peru.rb', line 68

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


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

def void(authorization, options = {})
  params = {}
  add_auth_order_id(params, authorization, options)
  commit('void', params, options)
end