Class: ActiveMerchant::Billing::PayuLatamGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::PayuLatamGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/payu_latam.rb
Constant Summary
collapse
- BRAND_MAP =
{
"visa" => "VISA",
"master" => "MASTERCARD",
"american_express" => "AMEX",
"diners_club" => "DINERS"
}
- MINIMUMS =
{
"ARS" => 1700,
"BRL" => 600,
"MXN" => 3900,
"PEN" => 500
}
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
-
#authorize(amount, payment_method, options = {}) ⇒ Object
-
#capture(amount, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ PayuLatamGateway
constructor
A new instance of PayuLatamGateway.
-
#purchase(amount, payment_method, options = {}) ⇒ Object
-
#refund(amount, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(payment_method, options = {}) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#verify(credit_card, options = {}) ⇒ Object
-
#verify_credentials ⇒ Object
-
#void(authorization, options = {}) ⇒ Object
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 PayuLatamGateway.
31
32
33
34
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 31
def initialize(options={})
requires!(options, :merchant_id, :account_id, :api_login, :api_key)
super
end
|
Instance Method Details
#authorize(amount, payment_method, options = {}) ⇒ Object
42
43
44
45
46
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 42
def authorize(amount, payment_method, options={})
post = {}
auth_or_sale(post, 'AUTHORIZATION', amount, payment_method, options)
commit('auth', post)
end
|
#capture(amount, authorization, options = {}) ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 48
def capture(amount, authorization, options={})
post = {}
add_credentials(post, 'SUBMIT_TRANSACTION')
add_transaction_type(post, 'CAPTURE')
add_reference(post, authorization)
commit('capture', post)
end
|
#purchase(amount, payment_method, options = {}) ⇒ Object
36
37
38
39
40
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 36
def purchase(amount, payment_method, options={})
post = {}
auth_or_sale(post, 'AUTHORIZATION_AND_CAPTURE', amount, payment_method, options)
commit('purchase', post)
end
|
#refund(amount, authorization, options = {}) ⇒ Object
68
69
70
71
72
73
74
75
76
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 68
def refund(amount, authorization, options={})
post = {}
add_credentials(post, 'SUBMIT_TRANSACTION')
add_transaction_type(post, 'REFUND')
add_reference(post, authorization)
commit('refund', post)
end
|
#scrub(transcript) ⇒ Object
108
109
110
111
112
113
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 108
def scrub(transcript)
transcript.
gsub(%r((\"creditCard\\\":{\\\"number\\\":\\\")\d+), '\1[FILTERED]').
gsub(%r((\"securityCode\\\":\\\")\d+), '\1[FILTERED]').
gsub(%r((\"apiKey\\\":\\\")\w+), '\1[FILTERED]')
end
|
#store(payment_method, options = {}) ⇒ Object
88
89
90
91
92
93
94
95
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 88
def store(payment_method, options = {})
post = {}
add_credentials(post, 'CREATE_TOKEN')
add_payment_method_to_be_tokenized(post, payment_method)
commit('store', post)
end
|
#supports_scrubbing? ⇒ Boolean
104
105
106
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 104
def supports_scrubbing?
true
end
|
#verify(credit_card, options = {}) ⇒ Object
78
79
80
81
82
83
84
85
86
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 78
def verify(credit_card, options={})
minimum = MINIMUMS[options[:currency].upcase] if options[:currency]
amount = minimum || 100
MultiResponse.run(:use_first_response) do |r|
r.process { authorize(amount, credit_card, options) }
r.process(:ignore_result) { void(r.authorization, options) }
end
end
|
#verify_credentials ⇒ Object
97
98
99
100
101
102
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 97
def verify_credentials
post = {}
add_credentials(post, 'GET_PAYMENT_METHODS')
response = commit('verify_credentials', post)
response.success?
end
|
#void(authorization, options = {}) ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 58
def void(authorization, options={})
post = {}
add_credentials(post, 'SUBMIT_TRANSACTION')
add_transaction_type(post, 'VOID')
add_reference(post, authorization)
commit('void', post)
end
|