class Stall::Payments::UrlsConfig

Attributes

cart[R]
payment_failure_return_url[RW]
payment_notification_url[RW]
payment_success_return_url[RW]

Public Class Methods

new(cart) click to toggle source
# File lib/stall/payments/urls_config.rb, line 14
def initialize(cart)
  @cart = cart

  # Parse URLs
  instance_exec(self, &config_block)
end

Private Instance Methods

config_block() click to toggle source
# File lib/stall/payments/urls_config.rb, line 23
def config_block
  self.class.config_block || default_config
end
default_config() click to toggle source
# File lib/stall/payments/urls_config.rb, line 27
def default_config
  ->(urls) {
    urls.payment_notification_url   = notify_payment_url(gateway: gateway_identifier, host: Stall.config.default_app_domain)
    urls.payment_success_return_url = process_checkout_step_url(cart.identifier, host: Stall.config.default_app_domain, succeeded: true)
    urls.payment_failure_return_url = process_checkout_step_url(cart.identifier, host: Stall.config.default_app_domain, aborted: true)
  }
end
gateway_identifier() click to toggle source
# File lib/stall/payments/urls_config.rb, line 35
def gateway_identifier
  @gateway_identifier ||= cart.payment.payment_method.identifier
end