lib/pay/stripe.rb in pay-6.8.1 vs lib/pay/stripe.rb in pay-7.0.0

- old
+ new

@@ -28,11 +28,11 @@ autoload :SubscriptionTrialWillEnd, "pay/stripe/webhooks/subscription_trial_will_end" end extend Env - REQUIRED_VERSION = "~> 9" + REQUIRED_VERSION = "~> 10" # A list of database model names that include Pay # Used for safely looking up models with client_reference_id mattr_accessor :model_names, default: Set.new @@ -42,11 +42,10 @@ Pay::Engine.version_matches?(required: REQUIRED_VERSION, current: ::Stripe::VERSION) || (raise "[Pay] stripe gem must be version #{REQUIRED_VERSION}") end def self.setup ::Stripe.api_key = private_key - ::Stripe.api_version ||= "2023-08-16" # Used by Stripe to identify Pay for support ::Stripe.set_app_info("PayRails", partner_id: "pp_partner_IqhY0UExnJYLxg", version: Pay::VERSION, url: "https://github.com/pay-rails/pay") # Automatically retry requests that fail @@ -121,16 +120,16 @@ end end def self.to_client_reference_id(record) raise ArgumentError, "#{record.class.name} does not include Pay. Allowed models: #{model_names.to_a.join(", ")}" unless model_names.include?(record.class.name) - [record.class.name, record.id].join("/") + [record.class.name, record.id].join("_") end def self.find_by_client_reference_id(client_reference_id) # If there is a client reference ID, make sure we have a Pay::Customer record # client_reference_id should be in the format of "User/1" - model_name, id = client_reference_id.split("/", 2) + model_name, id = client_reference_id.split("_", 2) # Only allow model names that use Pay return unless model_names.include?(model_name) model_name.constantize.find(id)