pay 7.1.1 → 7.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/app/models/pay/subscription.rb +2 -2
- data/lib/pay/fake_processor/billable.rb +3 -2
- data/lib/pay/paddle_billing/charge.rb +2 -2
- data/lib/pay/paddle_billing/payment_method.rb +8 -1
- data/lib/pay/paddle_billing/subscription.rb +3 -3
- data/lib/pay/stripe/subscription.rb +1 -1
- data/lib/pay/stripe.rb +1 -1
- 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: b50cc63cfa61beffbc725d9f6c623c469a6357e0808ff06d3e814c4aa4e19955
|
4
|
+
data.tar.gz: ae87dbfcd24862baa2f156cb2b1b94fe836a0d113853b562cbe59835e59569c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 459524ff5b772a08c1ee1d994088b71f0e9a854f4b1afa76ecdb60fa8229f43ea72ed327a6dbf55d497478d033f99f1d19c4ed978c69931e27ad9ddc99fd57af
|
7
|
+
data.tar.gz: 200898e080a94d76520e0a85088d43691f64a27da3d94ac4fa74a9f14db4f6a5c1bdc16992422b3f4c4ab9b63bb35344e099799984cca0beb4cff8a6dc6e8512
|
data/README.md
CHANGED
@@ -44,7 +44,7 @@ Want to add a new payment provider? Contributions are welcome.
|
|
44
44
|
* **Payment Processors**
|
45
45
|
* [Stripe](docs/stripe/1_overview.md)
|
46
46
|
* [Braintree](docs/braintree/1_overview.md)
|
47
|
-
* [Paddle](docs/
|
47
|
+
* [Paddle](docs/paddle_billing/1_overview.md)
|
48
48
|
* [Fake Processor](docs/fake_processor/1_overview.md)
|
49
49
|
* **Marketplaces**
|
50
50
|
* [Stripe Connect](docs/marketplaces/stripe_connect.md)
|
@@ -55,6 +55,10 @@ Want to add a new payment provider? Contributions are welcome.
|
|
55
55
|
|
56
56
|
If you have an issue you'd like to submit, please do so using the issue tracker in GitHub. In order for us to help you in the best way possible, please be as detailed as you can.
|
57
57
|
|
58
|
+
For those using devcontainers, if you want to test the application with different databases:
|
59
|
+
1. Uncomment the `DATABASE_URL` corresponding to the database type you wish to use in the `.devcontainer/devcontainer.json` file.
|
60
|
+
2. Rebuild the devcontainer, which will configure the application to use the selected database for your development environment.
|
61
|
+
|
58
62
|
If you'd like to open a PR please make sure the following things pass:
|
59
63
|
|
60
64
|
```ruby
|
@@ -9,11 +9,11 @@ module Pay
|
|
9
9
|
|
10
10
|
# Scopes
|
11
11
|
scope :for_name, ->(name) { where(name: name) }
|
12
|
-
scope :on_trial, -> { where("trial_ends_at > ?", Time.current) }
|
12
|
+
scope :on_trial, -> { where(status: ["trialing", "active"]).where("trial_ends_at > ?", Time.current) }
|
13
13
|
scope :canceled, -> { where.not(ends_at: nil) }
|
14
14
|
scope :cancelled, -> { canceled }
|
15
15
|
scope :on_grace_period, -> { where("#{table_name}.ends_at IS NOT NULL AND #{table_name}.ends_at > ?", Time.current) }
|
16
|
-
scope :active, -> { where(status:
|
16
|
+
scope :active, -> { where(status: "active").pause_not_started.where("#{table_name}.ends_at IS NULL OR #{table_name}.ends_at > ?", Time.current).or(on_trial) }
|
17
17
|
scope :paused, -> { where(status: "paused").or(where("pause_starts_at <= ?", Time.current)) }
|
18
18
|
scope :pause_not_started, -> { where("pause_starts_at IS NULL OR pause_starts_at > ?", Time.current) }
|
19
19
|
scope :active_or_paused, -> { active.or(paused) }
|
@@ -28,7 +28,8 @@ module Pay
|
|
28
28
|
# Make to generate a processor_id
|
29
29
|
customer
|
30
30
|
|
31
|
-
|
31
|
+
valid_attributes = options.slice(*Pay::Charge.attribute_names.map(&:to_sym))
|
32
|
+
attributes = {
|
32
33
|
processor_id: NanoId.generate,
|
33
34
|
amount: amount,
|
34
35
|
data: {
|
@@ -38,7 +39,7 @@ module Pay
|
|
38
39
|
exp_month: Date.today.month,
|
39
40
|
exp_year: Date.today.year
|
40
41
|
}
|
41
|
-
)
|
42
|
+
}.deep_merge(valid_attributes)
|
42
43
|
pay_customer.charges.create!(attributes)
|
43
44
|
end
|
44
45
|
|
@@ -37,8 +37,8 @@ module Pay
|
|
37
37
|
subscription: pay_customer.subscriptions.find_by(processor_id: object.subscription_id)
|
38
38
|
}
|
39
39
|
|
40
|
-
if object.
|
41
|
-
case
|
40
|
+
if (details = Array.wrap(object.payments).first&.method_details)
|
41
|
+
case details.type.downcase
|
42
42
|
when "card"
|
43
43
|
attrs[:payment_method_type] = "card"
|
44
44
|
attrs[:brand] = details.card.type
|
@@ -5,6 +5,13 @@ module Pay
|
|
5
5
|
|
6
6
|
delegate :customer, :processor_id, to: :pay_payment_method
|
7
7
|
|
8
|
+
def self.sync_from_transaction(pay_customer:, transaction:)
|
9
|
+
transaction = ::Paddle::Transaction.retrieve(id: transaction)
|
10
|
+
return unless transaction.status == "completed"
|
11
|
+
return if transaction.payments.empty?
|
12
|
+
sync(pay_customer: pay_customer, attributes: transaction.payments.first)
|
13
|
+
end
|
14
|
+
|
8
15
|
def self.sync(pay_customer:, attributes:)
|
9
16
|
details = attributes.method_details
|
10
17
|
attrs = {
|
@@ -19,7 +26,7 @@ module Pay
|
|
19
26
|
attrs[:exp_year] = details.card.expiry_year
|
20
27
|
end
|
21
28
|
|
22
|
-
payment_method = pay_customer.payment_methods.find_or_initialize_by(processor_id: attributes.
|
29
|
+
payment_method = pay_customer.payment_methods.find_or_initialize_by(processor_id: attributes.payment_method_id)
|
23
30
|
payment_method.update!(attrs)
|
24
31
|
payment_method
|
25
32
|
end
|
@@ -56,9 +56,9 @@ module Pay
|
|
56
56
|
# Remove payment methods since customer cannot be reused after cancelling
|
57
57
|
Pay::PaymentMethod.where(customer_id: object.customer_id).destroy_all
|
58
58
|
when "trialing"
|
59
|
-
attributes[:trial_ends_at] = Time.parse(object.next_billed_at)
|
59
|
+
attributes[:trial_ends_at] = Time.parse(object.next_billed_at) if object.next_billed_at
|
60
60
|
when "paused"
|
61
|
-
attributes[:pause_starts_at] = Time.parse(object.paused_at)
|
61
|
+
attributes[:pause_starts_at] = Time.parse(object.paused_at) if object.paused_at
|
62
62
|
when "active", "past_due"
|
63
63
|
attributes[:trial_ends_at] = nil
|
64
64
|
attributes[:pause_starts_at] = nil
|
@@ -109,7 +109,7 @@ module Pay
|
|
109
109
|
)
|
110
110
|
pay_subscription.update(
|
111
111
|
status: response.status,
|
112
|
-
ends_at: response.scheduled_change.
|
112
|
+
ends_at: response.scheduled_change&.effective_at || Time.current
|
113
113
|
)
|
114
114
|
rescue ::Paddle::Error => e
|
115
115
|
raise Pay::PaddleBilling::Error, e
|
@@ -207,7 +207,7 @@ module Pay
|
|
207
207
|
# cancel_now!(prorate: true)
|
208
208
|
# cancel_now!(invoice_now: true)
|
209
209
|
def cancel_now!(**options)
|
210
|
-
return if canceled?
|
210
|
+
return if canceled? && ends_at.past?
|
211
211
|
|
212
212
|
@stripe_subscription = ::Stripe::Subscription.cancel(processor_id, options.merge(expand_options), stripe_options)
|
213
213
|
pay_subscription.update(ends_at: Time.current, status: :canceled)
|
data/lib/pay/stripe.rb
CHANGED
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: 7.
|
4
|
+
version: 7.2.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: 2024-
|
13
|
+
date: 2024-05-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
176
|
- !ruby/object:Gem::Version
|
177
177
|
version: '0'
|
178
178
|
requirements: []
|
179
|
-
rubygems_version: 3.5.
|
179
|
+
rubygems_version: 3.5.6
|
180
180
|
signing_key:
|
181
181
|
specification_version: 4
|
182
182
|
summary: Payments engine for Ruby on Rails
|