lib/pay.rb in pay-3.0.24 vs lib/pay.rb in pay-4.0.0
- old
+ new
@@ -33,14 +33,10 @@
mattr_accessor :business_address
mattr_accessor :business_name
mattr_accessor :business_logo
mattr_accessor :support_email
- # Email configuration
- mattr_accessor :send_emails
- @@send_emails = true
-
mattr_accessor :automount_routes
@@automount_routes = true
mattr_accessor :default_product_name
@@default_product_name = "default"
@@ -49,9 +45,32 @@
@@default_plan_name = "default"
mattr_accessor :routes_path
@@routes_path = "/pay"
+ mattr_accessor :enabled_processors
+ @@enabled_processors = [:stripe, :braintree, :paddle]
+
+ mattr_accessor :emails
+ @@emails = ActiveSupport::OrderedOptions.new
+ @@emails.payment_action_required = true
+ @@emails.receipt = true
+ @@emails.refund = true
+ # This only applies to Stripe, therefor we supply the second argument of price
+ @@emails.subscription_renewing = ->(pay_subscription, price) {
+ (price&.type == "recurring") && (price.recurring&.interval == "year")
+ }
+
def self.setup
yield self
+ end
+
+ def self.send_email?(email_option, *remaining_args)
+ config_option = emails.send(email_option)
+
+ if config_option.respond_to?(:call)
+ config_option.call(*remaining_args)
+ else
+ config_option
+ end
end
end