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
35
|
# 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
@options[:payment_country] ||= options[:payment_country] if options[:payment_country]
end
|
Instance Method Details
#authorize(amount, payment_method, options = {}) ⇒ Object
43
44
45
46
47
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 43
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
49
50
51
52
53
54
55
56
57
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 49
def capture(amount, authorization, options={})
post = {}
add_credentials(post, 'SUBMIT_TRANSACTION')
add_transaction_elements(post, 'CAPTURE', options)
add_reference(post, authorization)
commit('capture', post)
end
|
#purchase(amount, payment_method, options = {}) ⇒ Object
37
38
39
40
41
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 37
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
69
70
71
72
73
74
75
76
77
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 69
def refund(amount, authorization, options={})
post = {}
add_credentials(post, 'SUBMIT_TRANSACTION')
add_transaction_elements(post, 'REFUND', options)
add_reference(post, authorization)
commit('refund', post)
end
|
#scrub(transcript) ⇒ Object
109
110
111
112
113
114
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 109
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
89
90
91
92
93
94
95
96
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 89
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
105
106
107
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 105
def supports_scrubbing?
true
end
|
#verify(credit_card, options = {}) ⇒ Object
79
80
81
82
83
84
85
86
87
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 79
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
98
99
100
101
102
103
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 98
def verify_credentials
post = {}
add_credentials(post, 'GET_PAYMENT_METHODS')
response = commit('verify_credentials', post)
response.success?
end
|
#void(authorization, options = {}) ⇒ Object
59
60
61
62
63
64
65
66
67
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 59
def void(authorization, options={})
post = {}
add_credentials(post, 'SUBMIT_TRANSACTION')
add_transaction_elements(post, 'VOID', options)
add_reference(post, authorization)
commit('void', post)
end
|