pay 11.6.1 → 11.7.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b562e4a4f9648149c46c4932ad4c770cb6c9f93bc424b84ba8619cb7282170bc
4
- data.tar.gz: c8328e7c5b1d4770131515d56fcd8b8a6170f6d427bbda29159d00d8dd8244f3
3
+ metadata.gz: d601b9570c286a5518fad5444be12f07069b6d0b8afe8a879089040f77c7f7be
4
+ data.tar.gz: 1b81304fce9611e742d5cc2c8638a51634f174b9f68a319c47956329c8e7e183
5
5
  SHA512:
6
- metadata.gz: 272d38c42d2be1bfaf55929c429b15164c2dd2f64eca8571f4d868a0df0262f8599b5ac81c23539cf24c8a263b5bc8670b7f075871d79abdae1fa4983474ded4
7
- data.tar.gz: d56318ddb06905b38bf3869b8dea5415ff8159b0a1b70d0e228389e1f23cc060a8fbe153028f682e7b6775688aae82a7d2514b560ea965e089b6076a339acb16
6
+ metadata.gz: de12f02fef6df24c30a05bf5e42b8905cac6ecdd258015d63e9b58e1985c930c5deae3f6992d92d3efd7b3cdae0f37a7ec8309c4fb85bb5956685c9f84374abe
7
+ data.tar.gz: f81848b21ebb2b75511aa6ed8fdd7df9f68449a8ac497669690de7310e2c3a3a5a4b795fce6017e11494dc2138b12b7829675ae5f9e8533a3cf63ce9d6f7358c
@@ -36,7 +36,8 @@ module Pay
36
36
  digest = OpenSSL::Digest.new("sha256")
37
37
 
38
38
  hmac = OpenSSL::HMAC.hexdigest(digest, key, data)
39
- hmac == h1
39
+ return false if h1.nil? || hmac.bytesize != h1.bytesize
40
+ ActiveSupport::SecurityUtils.secure_compare(hmac, h1)
40
41
  end
41
42
 
42
43
  def verify_params
@@ -2,7 +2,7 @@ module Pay
2
2
  class UserMailer < Pay.parent_mailer.constantize
3
3
  def receipt
4
4
  if params[:pay_charge].respond_to? :receipt
5
- attachments[params[:pay_charge].filename] = params[:pay_charge].receipt
5
+ attachments[params[:pay_charge].receipt_filename] = params[:pay_charge].receipt
6
6
  end
7
7
 
8
8
  mail mail_arguments
@@ -175,7 +175,7 @@ module Pay
175
175
  }
176
176
 
177
177
  # Hosted (the default) checkout sessions require a success_url and cancel_url
178
- if ["", "hosted"].include? options[:ui_mode].to_s
178
+ if ["", "hosted_page"].include?(options[:ui_mode].to_s)
179
179
  args[:success_url] = merge_session_id_param(options.delete(:success_url) || root_url)
180
180
  args[:cancel_url] = merge_session_id_param(options.delete(:cancel_url) || root_url)
181
181
  end
@@ -334,7 +334,7 @@ module Pay
334
334
 
335
335
  # Retries the latest invoice for a Past Due subscription and attempts to pay it
336
336
  def retry_failed_payment(payment_intent_id: nil)
337
- payment_intent_id ||= api_record.latest_invoice.payment_intent.id
337
+ payment_intent_id ||= api_record.latest_invoice.payments.first.payment.payment_intent
338
338
  payment_intent = ::Stripe::PaymentIntent.retrieve({id: payment_intent_id}, stripe_options)
339
339
 
340
340
  payment_intent = if payment_intent.status == "requires_payment_method"
@@ -3,7 +3,7 @@ module Pay
3
3
  STATUSES = %w[incomplete incomplete_expired trialing active past_due canceled unpaid paused]
4
4
 
5
5
  # Associations
6
- belongs_to :customer
6
+ belongs_to :customer, touch: true
7
7
  belongs_to :payment_method, optional: true, primary_key: :processor_id
8
8
  has_many :charges
9
9
 
data/lib/pay/stripe.rb CHANGED
@@ -43,6 +43,15 @@ module Pay
43
43
  def self.setup
44
44
  ::Stripe.api_key = private_key
45
45
 
46
+ # When private_key is a Stripe Organizations API key (sk_org_...),
47
+ # every request must identify the target account with the
48
+ # Stripe-Context header. stripe-ruby applies this configuration to all
49
+ # requests automatically. Regular account keys set no context and are
50
+ # unaffected. https://docs.stripe.com/keys/organization-api-keys
51
+ # (Assigned through Stripe.config: the Stripe module delegates
52
+ # stripe_account but not stripe_context.)
53
+ ::Stripe.config.stripe_context = context if context
54
+
46
55
  # Used by Stripe to identify Pay for support
47
56
  ::Stripe.set_app_info("PayRails", partner_id: "pp_partner_IqhY0UExnJYLxg", version: Pay::VERSION, url: "https://github.com/pay-rails/pay")
48
57
 
@@ -60,6 +69,14 @@ module Pay
60
69
  find_value_by_name(:stripe, :private_key)
61
70
  end
62
71
 
72
+ # Optional. The account (acct_...) that API requests should act on when
73
+ # using a Stripe Organizations API key. Resolved like every other Stripe
74
+ # credential: ENV["STRIPE_CONTEXT"], then env-scoped, then unscoped
75
+ # Rails credentials.
76
+ def self.context
77
+ find_value_by_name(:stripe, :context)
78
+ end
79
+
63
80
  def self.signing_secret
64
81
  find_value_by_name(:stripe, :signing_secret)
65
82
  end
@@ -115,6 +132,7 @@ module Pay
115
132
  # If a customer's payment source was deleted in Stripe, we should update as well
116
133
  events.subscribe "stripe.payment_method.attached", Pay::Stripe::Webhooks::PaymentMethodAttached.new
117
134
  events.subscribe "stripe.payment_method.updated", Pay::Stripe::Webhooks::PaymentMethodUpdated.new
135
+ events.subscribe "stripe.payment_method.automatically_updated", Pay::Stripe::Webhooks::PaymentMethodUpdated.new
118
136
  events.subscribe "stripe.payment_method.card_automatically_updated", Pay::Stripe::Webhooks::PaymentMethodUpdated.new
119
137
  events.subscribe "stripe.payment_method.detached", Pay::Stripe::Webhooks::PaymentMethodDetached.new
120
138
 
data/lib/pay/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "11.6.1"
2
+ VERSION = "11.7.0"
3
3
  end
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: 11.6.1
4
+ version: 11.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  requirements: []
192
- rubygems_version: 4.0.3
192
+ rubygems_version: 4.0.17
193
193
  specification_version: 4
194
194
  summary: Payments engine for Ruby on Rails
195
195
  test_files: []