pay 6.7.2 → 6.8.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: 1af316b3951f2b2d0844c3fcfebc005f43a42cca3f2704eb19cde32df968f787
4
- data.tar.gz: d22bc794be545843843ba97e03ac9190e3835ec61c288aeb2e14fe562be055dc
3
+ metadata.gz: de3a99204ee0e081f59774da0369b8e820a8d1fb33d810871dbc62ec009012c1
4
+ data.tar.gz: 19bbcd3c80230b270b2fc60338d410d6ceb37e2dc9466d1674f8552ecbdf46e9
5
5
  SHA512:
6
- metadata.gz: a855e7acead57687470d16476fdee052649ae15977f21e611fbf529d337551895696310fbdc7f62d9242142f737de3c4045077c4208d79aa6bb38313467003c9
7
- data.tar.gz: d9071f2afbb72357256e78997a0617d4edbc5fbb1f904fc2a9afaff3078e2f19fbe8fa6b9b39708e75b0cba27b16f9dd9778be86514f0fdaabaacf86aa105be3
6
+ metadata.gz: 0f504f26b84e856d1fd241e61537f1203539b76f58f9af69a768316e97e710ff24b5a79ac2179a1c335d5691283dc9e097476e696b1551ec212046f8dd97f026
7
+ data.tar.gz: 87e4ae3cc89868ed3faa76e3a73b0aaba568c87d33e7c1c003619c4fc69887edcce7fab67f3c40cb57924423a4f9c0b2328cebf1491164ae975c79f586fa7cb9
@@ -5,11 +5,11 @@ module Pay
5
5
  module Webhooks
6
6
  class SubscriptionChargedUnsuccessfully
7
7
  def call(event)
8
- subscription = event.subscription
9
- return if subscription.nil?
8
+ # subscription = event.subscription
9
+ # return if subscription.nil?
10
10
 
11
- pay_subscription = Pay::Subscription.find_by_processor_and_id(:braintree, subscription.id)
12
- return unless pay_subscription.present?
11
+ # pay_subscription = Pay::Subscription.find_by_processor_and_id(:braintree, subscription.id)
12
+ # return unless pay_subscription.present?
13
13
 
14
14
  # pay_customer = pay_subscription.customer
15
15
  # pay_charge = Pay::Braintree::Billable.new(pay_customer).save_transaction(subscription.transactions.first)
@@ -77,20 +77,17 @@ module Pay
77
77
  )
78
78
  end
79
79
 
80
+ # Charges an amount to the customer's default payment method
80
81
  def charge(amount, options = {})
81
82
  add_payment_method(payment_method_token, default: true) if payment_method_token?
82
83
 
83
84
  payment_method = pay_customer.default_payment_method
84
85
  args = {
85
- amount: amount,
86
86
  confirm: true,
87
- currency: "usd",
88
- customer: processor_id,
89
- expand: ["latest_charge.refunds"],
90
87
  payment_method: payment_method&.processor_id
91
88
  }.merge(options)
92
89
 
93
- payment_intent = ::Stripe::PaymentIntent.create(args, stripe_options)
90
+ payment_intent = create_payment_intent(amount, args)
94
91
  Pay::Payment.new(payment_intent).validate
95
92
 
96
93
  charge = payment_intent.latest_charge
@@ -99,6 +96,24 @@ module Pay
99
96
  raise Pay::Stripe::Error, e
100
97
  end
101
98
 
99
+ # Creates and returns a Stripe::PaymentIntent
100
+ def create_payment_intent(amount, options = {})
101
+ args = {
102
+ amount: amount,
103
+ currency: "usd",
104
+ customer: processor_id,
105
+ expand: ["latest_charge.refunds"],
106
+ return_url: root_url
107
+ }.merge(options)
108
+
109
+ ::Stripe::PaymentIntent.create(args, stripe_options)
110
+ end
111
+
112
+ # Used for creating Stripe Terminal charges
113
+ def terminal_charge(amount, options = {})
114
+ create_payment_intent(amount, options.merge(payment_method_types: ["card_present"], capture_method: "manual"))
115
+ end
116
+
102
117
  def subscribe(name: Pay.default_product_name, plan: Pay.default_plan_name, **options)
103
118
  quantity = options.delete(:quantity)
104
119
  opts = {
data/lib/pay/stripe.rb CHANGED
@@ -30,6 +30,8 @@ module Pay
30
30
 
31
31
  extend Env
32
32
 
33
+ REQUIRED_VERSION = "~> 9"
34
+
33
35
  # A list of database model names that include Pay
34
36
  # Used for safely looking up models with client_reference_id
35
37
  mattr_accessor :model_names, default: Set.new
@@ -37,12 +39,12 @@ module Pay
37
39
  def self.enabled?
38
40
  return false unless Pay.enabled_processors.include?(:stripe) && defined?(::Stripe)
39
41
 
40
- Pay::Engine.version_matches?(required: "~> 8", current: ::Stripe::VERSION) || (raise "[Pay] stripe gem must be version ~> 8")
42
+ Pay::Engine.version_matches?(required: REQUIRED_VERSION, current: ::Stripe::VERSION) || (raise "[Pay] stripe gem must be version #{REQUIRED_VERSION}")
41
43
  end
42
44
 
43
45
  def self.setup
44
46
  ::Stripe.api_key = private_key
45
- ::Stripe.api_version ||= "2022-11-15"
47
+ ::Stripe.api_version ||= "2023-08-16"
46
48
 
47
49
  # Used by Stripe to identify Pay for support
48
50
  ::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
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "6.7.2"
2
+ VERSION = "6.8.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: 6.7.2
4
+ version: 6.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-08-17 00:00:00.000000000 Z
13
+ date: 2023-08-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  - !ruby/object:Gem::Version
169
169
  version: '0'
170
170
  requirements: []
171
- rubygems_version: 3.4.18
171
+ rubygems_version: 3.4.19
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: Payments engine for Ruby on Rails