Module: Workarea::Storefront::AfterpayConfiguration
- Included in:
- Admin::AfterpayConfigurationViewModel
- Defined in:
- app/view_models/workarea/storefront/afterpay_configuration.rb
Defined Under Namespace
Classes: AfterpayConfigurationError
Instance Method Summary collapse
-
#afterpay_configuration(location) ⇒ Object
get the configuration for afterpay this will be used to determine elgibility for displaying the afterpay payment option.
Instance Method Details
#afterpay_configuration(location) ⇒ Object
get the configuration for afterpay this will be used to determine elgibility for displaying the afterpay payment option
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/view_models/workarea/storefront/afterpay_configuration.rb', line 8 def afterpay_configuration(location) merchant_id = Workarea::Afterpay.merchant_id(location) key = "afterpay_configuration/#{merchant_id}" afterpay_configuration = begin Rails.cache.fetch(key, expires_in: Workarea.config.cache_expirations.afterpay_configuration) do gateway = Workarea::Afterpay.gateway(location) response = gateway.get_configuration raise AfterpayConfigurationError unless response.success? response.body end end rescue # avoids caching a failed API response nil end |