Class: ActiveMerchant::Billing::VisanetPeruGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::VisanetPeruGateway
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::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, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?
#expdate, #format
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
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
39
40
|
# 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)
end
|
#capture(authorization, options = {}) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/active_merchant/billing/gateways/visanet_peru.rb', line 42
def capture(authorization, options={})
params = {}
_, purchase_number = split_authorization(authorization)
params[:purchaseNumber] = purchase_number
params[:externalTransactionId] = options[:order_id]
commit("deposit", params)
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(r.authorization, options) }
end
end
|
#scrub(transcript) ⇒ Object
75
76
77
78
79
80
|
# File 'lib/active_merchant/billing/gateways/visanet_peru.rb', line 75
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
71
72
73
|
# File 'lib/active_merchant/billing/gateways/visanet_peru.rb', line 71
def supports_scrubbing?
true
end
|
#verify(credit_card, options = {}) ⇒ Object
64
65
66
67
68
69
|
# File 'lib/active_merchant/billing/gateways/visanet_peru.rb', line 64
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
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/active_merchant/billing/gateways/visanet_peru.rb', line 50
def void(authorization, options={})
params = {}
action, purchase_number = split_authorization(authorization)
params[:purchaseNumber] = purchase_number
params[:externalTransactionId] = options[:order_id]
case action
when "authorize"
commit("void", params)
when "deposit"
commit("cancelDeposit", params)
end
end
|