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
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
#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
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/active_merchant/billing/gateways/wompi.rb', line 42
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
53
54
55
56
57
58
59
60
61
|
# File 'lib/active_merchant/billing/gateways/wompi.rb', line 53
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
|
# 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_card(post, payment, options)
commit('sale', post, '/transactions_sync')
end
|
#refund(money, authorization, options = {}) ⇒ Object
63
64
65
66
|
# File 'lib/active_merchant/billing/gateways/wompi.rb', line 63
def refund(money, authorization, options = {})
post = { amount_in_cents: amount(money).to_i, transaction_id: authorization.to_s }
commit('refund', post, '/refunds_sync')
end
|
#scrub(transcript) ⇒ Object
76
77
78
79
80
81
82
83
|
# File 'lib/active_merchant/billing/gateways/wompi.rb', line 76
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
72
73
74
|
# File 'lib/active_merchant/billing/gateways/wompi.rb', line 72
def supports_scrubbing?
true
end
|
#void(authorization, options = {}) ⇒ Object
68
69
70
|
# File 'lib/active_merchant/billing/gateways/wompi.rb', line 68
def void(authorization, options = {})
commit('void', {}, "/transactions/#{authorization}/void_sync")
end
|