pay 4.2.1 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pay might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/models/pay/customer.rb +9 -8
- data/lib/pay/stripe/subscription.rb +10 -3
- data/lib/pay/stripe.rb +2 -2
- data/lib/pay/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f7a284ee6da187cda76251887acb5192f351814f732b62708bec59ea1d016d80
         | 
| 4 | 
            +
              data.tar.gz: a9838d32ccf610468681a707f69c14958e1838e49ed3ab7399e0ef6ffaa5a679
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: dc25980ecdfbeacdab79c0e5834a1c5c7c6932e693f1fb44f260d0ad0a468b0d8be34267d3eadd4a5cebe6d564bcf05c3b0bfc98c36cef749caa14bb76cf6406
         | 
| 7 | 
            +
              data.tar.gz: 2654d78eeaddac5a8c923f895eab07619a0e960f19192a28e991b14bdb7d98a2963bed9e5d2bc54676e01c75d3ed5ea9e4a0c6c0f1cec52edaec31f6d89ce23e
         | 
    
        data/README.md
    CHANGED
    
    | @@ -20,7 +20,7 @@ Want to see how Pay works? Check out our video getting started guide. | |
| 20 20 |  | 
| 21 21 | 
             
            Our supported payment processors are:
         | 
| 22 22 |  | 
| 23 | 
            -
            - Stripe ([SCA Compatible](https://stripe.com/docs/strong-customer-authentication) using API version ` | 
| 23 | 
            +
            - Stripe ([SCA Compatible](https://stripe.com/docs/strong-customer-authentication) using API version `2022-08-01`)
         | 
| 24 24 | 
             
            - Paddle (SCA Compatible & supports PayPal)
         | 
| 25 25 | 
             
            - Braintree (supports PayPal)
         | 
| 26 26 | 
             
            - [Fake Processor](docs/fake_processor/1_overview.md) (used for generic trials without cards, free subscriptions, testing, etc)
         | 
    
        data/app/models/pay/customer.rb
    CHANGED
    
    | @@ -8,6 +8,7 @@ module Pay | |
| 8 8 |  | 
| 9 9 | 
             
                scope :active, -> { where(deleted_at: nil) }
         | 
| 10 10 | 
             
                scope :deleted, -> { where.not(deleted_at: nil) }
         | 
| 11 | 
            +
                scope :not_fake_processor, -> { where.not(processor: :fake_processor) }
         | 
| 11 12 |  | 
| 12 13 | 
             
                validates :processor, presence: true
         | 
| 13 14 | 
             
                validates :processor_id, allow_blank: true, uniqueness: {scope: :processor, case_sensitive: true}
         | 
| @@ -23,6 +24,14 @@ module Pay | |
| 23 24 | 
             
                delegate :email, to: :owner
         | 
| 24 25 | 
             
                delegate_missing_to :pay_processor
         | 
| 25 26 |  | 
| 27 | 
            +
                %w[stripe braintree paddle fake_processor].each do |processor_name|
         | 
| 28 | 
            +
                  scope processor_name, -> { where(processor: processor_name) }
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  define_method "#{processor_name}?" do
         | 
| 31 | 
            +
                    processor == processor_name
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
             | 
| 26 35 | 
             
                def self.pay_processor_for(name)
         | 
| 27 36 | 
             
                  "Pay::#{name.to_s.classify}::Billable".constantize
         | 
| 28 37 | 
             
                end
         | 
| @@ -83,13 +92,5 @@ module Pay | |
| 83 92 | 
             
                  # If these match, consider it a generic trial
         | 
| 84 93 | 
             
                  subscription.trial_ends_at == subscription.ends_at
         | 
| 85 94 | 
             
                end
         | 
| 86 | 
            -
             | 
| 87 | 
            -
                %w[stripe braintree paddle fake_processor].each do |processor_name|
         | 
| 88 | 
            -
                  scope processor_name, -> { where(processor: processor_name) }
         | 
| 89 | 
            -
             | 
| 90 | 
            -
                  define_method "#{processor_name}?" do
         | 
| 91 | 
            -
                    processor == processor_name
         | 
| 92 | 
            -
                  end
         | 
| 93 | 
            -
                end
         | 
| 94 95 | 
             
              end
         | 
| 95 96 | 
             
            end
         | 
| @@ -142,7 +142,7 @@ module Pay | |
| 142 142 | 
             
                  # cancel_now!(prorate: true)
         | 
| 143 143 | 
             
                  # cancel_now!(invoice_now: true)
         | 
| 144 144 | 
             
                  def cancel_now!(**options)
         | 
| 145 | 
            -
                    @stripe_subscription = ::Stripe::Subscription. | 
| 145 | 
            +
                    @stripe_subscription = ::Stripe::Subscription.cancel(processor_id, options.merge(expand_options), stripe_options)
         | 
| 146 146 | 
             
                    pay_subscription.update(ends_at: Time.current, status: :canceled)
         | 
| 147 147 | 
             
                  rescue ::Stripe::StripeError => e
         | 
| 148 148 | 
             
                    raise Pay::Stripe::Error, e
         | 
| @@ -240,16 +240,23 @@ module Pay | |
| 240 240 | 
             
                  # create_usage_record(quantity: 4, action: :increment)
         | 
| 241 241 | 
             
                  # create_usage_record(subscription_item_id: "si_1234", quantity: 100, action: :set)
         | 
| 242 242 | 
             
                  def create_usage_record(**options)
         | 
| 243 | 
            -
                    subscription_item_id = options.fetch(:subscription_item_id,  | 
| 243 | 
            +
                    subscription_item_id = options.fetch(:subscription_item_id, metered_subscription_item&.dig("id"))
         | 
| 244 244 | 
             
                    ::Stripe::SubscriptionItem.create_usage_record(subscription_item_id, options, stripe_options)
         | 
| 245 245 | 
             
                  end
         | 
| 246 246 |  | 
| 247 247 | 
             
                  # Returns usage record summaries for a subscription item
         | 
| 248 248 | 
             
                  def usage_record_summaries(**options)
         | 
| 249 | 
            -
                    subscription_item_id = options.fetch(:subscription_item_id,  | 
| 249 | 
            +
                    subscription_item_id = options.fetch(:subscription_item_id, metered_subscription_item&.dig("id"))
         | 
| 250 250 | 
             
                    ::Stripe::SubscriptionItem.list_usage_record_summaries(subscription_item_id, options, stripe_options)
         | 
| 251 251 | 
             
                  end
         | 
| 252 252 |  | 
| 253 | 
            +
                  # Returns the first metered subscription item
         | 
| 254 | 
            +
                  def metered_subscription_item
         | 
| 255 | 
            +
                    subscription_items.find do |subscription_item|
         | 
| 256 | 
            +
                      subscription_item.dig("price", "recurring", "usage_type") == "metered"
         | 
| 257 | 
            +
                    end
         | 
| 258 | 
            +
                  end
         | 
| 259 | 
            +
             | 
| 253 260 | 
             
                  # Returns an upcoming invoice for a subscription
         | 
| 254 261 | 
             
                  def upcoming_invoice(**options)
         | 
| 255 262 | 
             
                    ::Stripe::Invoice.upcoming(options.merge(subscription: processor_id), stripe_options)
         | 
    
        data/lib/pay/stripe.rb
    CHANGED
    
    | @@ -31,12 +31,12 @@ module Pay | |
| 31 31 | 
             
                def self.enabled?
         | 
| 32 32 | 
             
                  return false unless Pay.enabled_processors.include?(:stripe) && defined?(::Stripe)
         | 
| 33 33 |  | 
| 34 | 
            -
                  Pay::Engine.version_matches?(required: "~>  | 
| 34 | 
            +
                  Pay::Engine.version_matches?(required: "~> 7", current: ::Stripe::VERSION) || (raise "[Pay] stripe gem must be version ~> 7")
         | 
| 35 35 | 
             
                end
         | 
| 36 36 |  | 
| 37 37 | 
             
                def self.setup
         | 
| 38 38 | 
             
                  ::Stripe.api_key = private_key
         | 
| 39 | 
            -
                  ::Stripe.api_version = " | 
| 39 | 
            +
                  ::Stripe.api_version = "2022-08-01"
         | 
| 40 40 |  | 
| 41 41 | 
             
                  # Used by Stripe to identify Pay for support
         | 
| 42 42 | 
             
                  ::Stripe.set_app_info("PayRails", partner_id: "pp_partner_IqhY0UExnJYLxg", version: Pay::VERSION, url: "https://github.com/pay-rails/pay")
         | 
    
        data/lib/pay/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: pay
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version:  | 
| 4 | 
            +
              version: 5.0.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Jason Charnes
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire:
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2022-08- | 
| 12 | 
            +
            date: 2022-08-18 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: rails
         |