Class: ActiveMerchant::Billing::WompiGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::WompiGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/wompi.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
-
#authorize(money, payment, options = {}) ⇒ Object
-
#capture(money, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ WompiGateway
constructor
A new instance of WompiGateway.
-
#purchase(money, payment, options = {}) ⇒ Object
-
#refund(money, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#void(authorization, options = {}, money = nil) ⇒ 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, #strftime_yyyymm
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ WompiGateway
Returns a new instance of WompiGateway.
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/active_merchant/billing/gateways/wompi.rb', line 16
def initialize(options = {})
begin
requires!(options, :prod_private_key, :prod_public_key)
rescue ArgumentError
begin
requires!(options, :test_private_key, :test_public_key)
rescue ArgumentError
raise ArgumentError, 'Gateway requires both test_private_key and test_public_key, or both prod_private_key and prod_public_key'
end
end
super
end
|
Instance Method Details
#authorize(money, payment, options = {}) ⇒ Object
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/active_merchant/billing/gateways/wompi.rb', line 43
def authorize(money, payment, options = {})
post = {
public_key: public_key,
type: 'CARD',
financial_operation: 'PREAUTHORIZATION'
}
add_auth_params(post, money, payment, options)
commit('authorize', post, '/payment_sources_sync')
end
|
#capture(money, authorization, options = {}) ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'lib/active_merchant/billing/gateways/wompi.rb', line 54
def capture(money, authorization, options = {})
post = {
reference: options[:reference] || generate_reference,
public_key: public_key,
payment_source_id: authorization.to_i
}
add_invoice(post, money, options)
commit('capture', post, '/transactions_sync')
end
|
#purchase(money, payment, options = {}) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/active_merchant/billing/gateways/wompi.rb', line 31
def purchase(money, payment, options = {})
post = {
reference: options[:reference] || generate_reference,
public_key: public_key
}
add_invoice(post, money, options)
add_tip_in_cents(post, options)
add_card(post, payment, options)
commit('sale', post, '/transactions_sync')
end
|
#refund(money, authorization, options = {}) ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/active_merchant/billing/gateways/wompi.rb', line 64
def refund(money, authorization, options = {})
void(authorization, options, money)
end
|
#scrub(transcript) ⇒ Object
81
82
83
84
85
86
87
88
|
# File 'lib/active_merchant/billing/gateways/wompi.rb', line 81
def scrub(transcript)
transcript.gsub(/(Bearer )\w+/, '\1[REDACTED]').
gsub(/(\\\"number\\\":\\\")\d+/, '\1[REDACTED]').
gsub(/(\\\"cvc\\\":\\\")\d+/, '\1[REDACTED]').
gsub(/(\\\"phone_number\\\":\\\")\+?\d+/, '\1[REDACTED]').
gsub(/(\\\"email\\\":\\\")\S+\\\",/, '\1[REDACTED]\",').
gsub(/(\\\"legal_id\\\":\\\")\d+/, '\1[REDACTED]')
end
|
#supports_scrubbing? ⇒ Boolean
77
78
79
|
# File 'lib/active_merchant/billing/gateways/wompi.rb', line 77
def supports_scrubbing?
true
end
|
#void(authorization, options = {}, money = nil) ⇒ Object
72
73
74
75
|
# File 'lib/active_merchant/billing/gateways/wompi.rb', line 72
def void(authorization, options = {}, money = nil)
post = money ? { amount_in_cents: amount(money).to_i } : {}
commit('void', post, "/transactions/#{authorization}/void_sync")
end
|