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 +4 -4
- data/lib/pay/braintree/webhooks/subscription_charged_unsuccessfully.rb +4 -4
- data/lib/pay/stripe/billable.rb +20 -5
- data/lib/pay/stripe.rb +4 -2
- data/lib/pay/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de3a99204ee0e081f59774da0369b8e820a8d1fb33d810871dbc62ec009012c1
|
4
|
+
data.tar.gz: 19bbcd3c80230b270b2fc60338d410d6ceb37e2dc9466d1674f8552ecbdf46e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
data/lib/pay/stripe/billable.rb
CHANGED
@@ -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 =
|
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:
|
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 ||= "
|
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
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.
|
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-
|
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.
|
171
|
+
rubygems_version: 3.4.19
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: Payments engine for Ruby on Rails
|