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',
'naranja' => 'NARANJA',
'cabal' => 'CABAL'
}
- MINIMUMS =
{
'ARS' => 1700,
'BRL' => 600,
'MXN' => 3900,
'PEN' => 500
}
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
-
#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
#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?
#expdate, #format
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of PayuLatamGateway.
33
34
35
36
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 33
def initialize(options={})
requires!(options, :merchant_id, :account_id, :api_login, :api_key, :payment_country)
super
end
|
Instance Method Details
#authorize(amount, payment_method, options = {}) ⇒ Object
44
45
46
47
48
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 44
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 50
def capture(amount, authorization, options={})
post = {}
add_credentials(post, 'SUBMIT_TRANSACTION', options)
add_transaction_elements(post, 'CAPTURE', options)
add_reference(post, authorization)
if !amount.nil? && amount.to_f != 0.0
post[:transaction][:additionalValues] ||= {}
post[:transaction][:additionalValues][:TX_VALUE] = invoice_for(amount, options)[:TX_VALUE]
end
commit('capture', post)
end
|
#purchase(amount, payment_method, options = {}) ⇒ Object
38
39
40
41
42
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 38
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
75
76
77
78
79
80
81
82
83
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 75
def refund(amount, authorization, options={})
post = {}
add_credentials(post, 'SUBMIT_TRANSACTION', options)
add_transaction_elements(post, 'REFUND', options)
add_reference(post, authorization)
commit('refund', post)
end
|
#scrub(transcript) ⇒ Object
115
116
117
118
119
120
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 115
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
95
96
97
98
99
100
101
102
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 95
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
111
112
113
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 111
def supports_scrubbing?
true
end
|
#verify(credit_card, options = {}) ⇒ Object
85
86
87
88
89
90
91
92
93
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 85
def verify(credit_card, options={})
minimum = MINIMUMS[options[:currency].upcase] if options[:currency]
amount = options[:verify_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
104
105
106
107
108
109
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 104
def verify_credentials
post = {}
add_credentials(post, 'GET_PAYMENT_METHODS')
response = commit('verify_credentials', post)
response.success?
end
|
#void(authorization, options = {}) ⇒ Object
65
66
67
68
69
70
71
72
73
|
# File 'lib/active_merchant/billing/gateways/payu_latam.rb', line 65
def void(authorization, options={})
post = {}
add_credentials(post, 'SUBMIT_TRANSACTION', options)
add_transaction_elements(post, 'VOID', options)
add_reference(post, authorization)
commit('void', post)
end
|