Module: Workarea::Afterpay
- Defined in:
- lib/workarea/afterpay.rb,
lib/workarea/afterpay/engine.rb,
lib/workarea/afterpay/gateway.rb,
lib/workarea/afterpay/version.rb,
lib/workarea/afterpay/response.rb,
lib/workarea/afterpay/bogus_gateway.rb,
app/models/workarea/afterpay/configuration.rb,
app/services/workarea/afterpay/order_builder.rb
Defined Under Namespace
Classes: BogusGateway, Configuration, Engine, Gateway, OrderBuilder, Response
Constant Summary
collapse
- RETRY_ERROR_STATUSES =
500..599
- VERSION =
'2.1.2'.freeze
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
23
24
25
|
# File 'lib/workarea/afterpay.rb', line 23
def self.config
Workarea.config.afterpay
end
|
.credentials ⇒ Object
19
20
21
|
# File 'lib/workarea/afterpay.rb', line 19
def self.credentials
(Rails.application.secrets.afterpay || {}).deep_symbolize_keys
end
|
.gateway(location, options = {}) ⇒ Afterpay::Gateway
Conditionally use the real gateway when secrets are present. Otherwise, use the bogus gateway.
52
53
54
55
56
57
58
59
|
# File 'lib/workarea/afterpay.rb', line 52
def self.gateway(location, options = {})
if credentials.present?
options.merge!(location: location, test: test?)
Afterpay::Gateway.new(merchant_id(location), secret_key(location), options)
else
Afterpay::BogusGateway.new
end
end
|
.merchant_id(location) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/workarea/afterpay.rb', line 27
def self.merchant_id(location)
return unless credentials.present?
country = location.to_sym.downcase
return unless credentials[country].present?
credentials[country][:merchant_id]
end
|
.secret_key(location) ⇒ Object
37
38
39
40
41
42
|
# File 'lib/workarea/afterpay.rb', line 37
def self.secret_key(location)
return unless credentials.present?
country = location.to_sym.downcase
credentials[country][:secret_key]
end
|
.test? ⇒ Boolean
44
45
46
|
# File 'lib/workarea/afterpay.rb', line 44
def self.test?
config[:test]
end
|