pay 3.0.17 → 3.0.18
Sign up to get free protection for your applications and to get access to all the features.
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/mailers/pay/user_mailer.rb +1 -5
- data/app/models/pay/subscription.rb +4 -0
- data/lib/pay/braintree/webhooks/subscription_charged_successfully.rb +3 -3
- data/lib/pay/braintree/webhooks/subscription_charged_unsuccessfully.rb +3 -3
- data/lib/pay/paddle/subscription.rb +6 -0
- data/lib/pay/paddle/webhooks/subscription_cancelled.rb +1 -1
- data/lib/pay/paddle/webhooks/subscription_payment_refunded.rb +4 -7
- data/lib/pay/paddle/webhooks/subscription_payment_succeeded.rb +4 -4
- data/lib/pay/stripe/webhooks/charge_refunded.rb +2 -5
- data/lib/pay/stripe/webhooks/charge_succeeded.rb +2 -5
- data/lib/pay/stripe/webhooks/payment_action_required.rb +5 -6
- data/lib/pay/stripe/webhooks/subscription_renewing.rb +5 -5
- data/lib/pay/version.rb +1 -1
- data/lib/pay.rb +0 -8
- 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: a37f4ee9640c9f48545166512e3ce5dfd8f17555c6181794807db5a6cc88e4ac
|
4
|
+
data.tar.gz: 994889fa6c1e3c55b836d3597f95046eaed46d1c551154c57c83543312153965
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6e97f172fb3a5fbb9b62e3867fb29e363f9c5ea3f1fc385ab22a9ea59f27547ea84ca357eac1473e2ca4b25584d0c28f58f9124ca80e729cd5fa1da465d5b71
|
7
|
+
data.tar.gz: f455c3cc02a3b93f7eb5dd04c2edf0c67d0f72c3e2bddd3ced8e509a8b557705609b20dab00b0b40daab19734b46e097f2c4fcbe2f6aaf5df79f8291b75f6d3d
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ Our supported payment processors are:
|
|
23
23
|
- Stripe ([SCA Compatible](https://stripe.com/docs/strong-customer-authentication) using API version `2020-08-27`)
|
24
24
|
- Paddle (SCA Compatible & supports PayPal)
|
25
25
|
- Braintree (supports PayPal)
|
26
|
-
- [Fake Processor](docs/fake_processor.md) (used for generic trials without cards, free subscriptions, testing, etc)
|
26
|
+
- [Fake Processor](docs/fake_processor/1_overview.md) (used for generic trials without cards, free subscriptions, testing, etc)
|
27
27
|
|
28
28
|
Want to add a new payment provider? Contributions are welcome.
|
29
29
|
|
@@ -23,11 +23,7 @@ module Pay
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def to
|
26
|
-
|
27
|
-
"#{params[:billable].customer_name} <#{params[:billable].email}>"
|
28
|
-
else
|
29
|
-
params[:billable].email
|
30
|
-
end
|
26
|
+
"#{params[:pay_customer].customer_name} <#{params[:pay_customer].email}>"
|
31
27
|
end
|
32
28
|
end
|
33
29
|
end
|
@@ -12,10 +12,10 @@ module Pay
|
|
12
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)
|
16
16
|
|
17
|
-
if Pay.send_emails
|
18
|
-
Pay::UserMailer.with(
|
17
|
+
if pay_charge && Pay.send_emails
|
18
|
+
Pay::UserMailer.with(pay_customer: pay_customer, charge: pay_charge).receipt.deliver_later
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -11,11 +11,11 @@ module Pay
|
|
11
11
|
pay_subscription = Pay::Subscription.find_by_processor_and_id(:braintree, subscription.id)
|
12
12
|
return unless pay_subscription.present?
|
13
13
|
|
14
|
-
#
|
15
|
-
#
|
14
|
+
# pay_customer = pay_subscription.customer
|
15
|
+
# pay_charge = Pay::Braintree::Billable.new(pay_customer).save_transaction(subscription.transactions.first)
|
16
16
|
|
17
17
|
# if Pay.send_emails
|
18
|
-
# Pay::UserMailer.with(
|
18
|
+
# Pay::UserMailer.with(pay_customer: pay_charge.customer, charge: pay_charge).receipt.deliver_later
|
19
19
|
# end
|
20
20
|
end
|
21
21
|
end
|
@@ -78,6 +78,9 @@ module Pay
|
|
78
78
|
ends_at = on_trial? ? trial_ends_at : processor_subscription.next_payment[:date]
|
79
79
|
PaddlePay::Subscription::User.cancel(processor_id)
|
80
80
|
pay_subscription.update(status: :canceled, ends_at: ends_at)
|
81
|
+
|
82
|
+
# Remove payment methods since customer cannot be reused after cancelling
|
83
|
+
Pay::PaymentMethod.where(customer_id: pay_subscription.customer_id).destroy_all
|
81
84
|
rescue ::PaddlePay::PaddlePayError => e
|
82
85
|
raise Pay::Paddle::Error, e
|
83
86
|
end
|
@@ -85,6 +88,9 @@ module Pay
|
|
85
88
|
def cancel_now!
|
86
89
|
PaddlePay::Subscription::User.cancel(processor_id)
|
87
90
|
pay_subscription.update(status: :canceled, ends_at: Time.current)
|
91
|
+
|
92
|
+
# Remove payment methods since customer cannot be reused after cancelling
|
93
|
+
Pay::PaymentMethod.where(customer_id: pay_subscription.customer_id).destroy_all
|
88
94
|
rescue ::PaddlePay::PaddlePayError => e
|
89
95
|
raise Pay::Paddle::Error, e
|
90
96
|
end
|
@@ -13,7 +13,7 @@ module Pay
|
|
13
13
|
pay_subscription.update!(ends_at: Time.zone.parse(event.cancellation_effective_date)) if pay_subscription.ends_at.blank? && event.cancellation_effective_date.present?
|
14
14
|
|
15
15
|
# Paddle doesn't allow reusing customers, so we should remove their payment methods
|
16
|
-
pay_subscription.
|
16
|
+
Pay::PaymentMethod.where(customer_id: pay_subscription.customer_id).destroy_all
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -3,16 +3,13 @@ module Pay
|
|
3
3
|
module Webhooks
|
4
4
|
class SubscriptionPaymentRefunded
|
5
5
|
def call(event)
|
6
|
-
|
7
|
-
return unless
|
6
|
+
pay_charge = Pay::Charge.find_by_processor_and_id(:paddle, event.subscription_payment_id)
|
7
|
+
return unless pay_charge.present?
|
8
8
|
|
9
|
-
|
10
|
-
notify_user(charge.customer.owner, charge)
|
11
|
-
end
|
9
|
+
pay_charge.update(amount_refunded: (event.gross_refund.to_f * 100).to_i)
|
12
10
|
|
13
|
-
def notify_user(billable, charge)
|
14
11
|
if Pay.send_emails
|
15
|
-
Pay::UserMailer.with(
|
12
|
+
Pay::UserMailer.with(pay_customer: pay_charge.customer, charge: pay_charge).refund.deliver_later
|
16
13
|
end
|
17
14
|
end
|
18
15
|
end
|
@@ -18,7 +18,7 @@ module Pay
|
|
18
18
|
return if pay_customer.charges.where(processor_id: event.subscription_payment_id).any?
|
19
19
|
|
20
20
|
charge = create_charge(pay_customer, event)
|
21
|
-
notify_user(
|
21
|
+
notify_user(charge)
|
22
22
|
end
|
23
23
|
|
24
24
|
def create_charge(pay_customer, event)
|
@@ -42,9 +42,9 @@ module Pay
|
|
42
42
|
charge
|
43
43
|
end
|
44
44
|
|
45
|
-
def notify_user(
|
46
|
-
if Pay.send_emails
|
47
|
-
Pay::UserMailer.with(
|
45
|
+
def notify_user(pay_charge)
|
46
|
+
if Pay.send_emails
|
47
|
+
Pay::UserMailer.with(pay_customer: pay_charge.customer, charge: pay_charge).receipt.deliver_later
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -4,12 +4,9 @@ module Pay
|
|
4
4
|
class ChargeRefunded
|
5
5
|
def call(event)
|
6
6
|
pay_charge = Pay::Stripe::Charge.sync(event.data.object.id, stripe_account: event.try(:account))
|
7
|
-
notify_user(pay_charge.customer.owner, pay_charge) if pay_charge
|
8
|
-
end
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
Pay::UserMailer.with(billable: billable, charge: charge).refund.deliver_later
|
8
|
+
if pay_charge && Pay.send_emails
|
9
|
+
Pay::UserMailer.with(pay_customer: pay_charge.customer, charge: pay_charge).refund.deliver_later
|
13
10
|
end
|
14
11
|
end
|
15
12
|
end
|
@@ -4,12 +4,9 @@ module Pay
|
|
4
4
|
class ChargeSucceeded
|
5
5
|
def call(event)
|
6
6
|
pay_charge = Pay::Stripe::Charge.sync(event.data.object.id, stripe_account: event.try(:account))
|
7
|
-
notify_user(pay_charge.customer.owner, pay_charge) if pay_charge
|
8
|
-
end
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
Pay::UserMailer.with(billable: billable, charge: charge).receipt.deliver_later
|
8
|
+
if pay_charge && Pay.send_emails
|
9
|
+
Pay::UserMailer.with(pay_customer: pay_charge.customer, charge: pay_charge).receipt.deliver_later
|
13
10
|
end
|
14
11
|
end
|
15
12
|
end
|
@@ -10,14 +10,13 @@ module Pay
|
|
10
10
|
|
11
11
|
subscription = Pay::Subscription.find_by_processor_and_id(:stripe, object.subscription)
|
12
12
|
return if subscription.nil?
|
13
|
-
billable = subscription.customer.owner
|
14
13
|
|
15
|
-
notify_user(billable, event.data.object.payment_intent, subscription)
|
16
|
-
end
|
17
|
-
|
18
|
-
def notify_user(billable, payment_intent_id, subscription)
|
19
14
|
if Pay.send_emails
|
20
|
-
Pay::UserMailer.with(
|
15
|
+
Pay::UserMailer.with(
|
16
|
+
pay_customer: subscription.customer,
|
17
|
+
payment_intent_id: event.data.object.payment_intent,
|
18
|
+
subscription: subscription
|
19
|
+
).payment_action_required.deliver_later
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
@@ -18,12 +18,12 @@ module Pay
|
|
18
18
|
interval = price.recurring.interval
|
19
19
|
return unless interval == "year"
|
20
20
|
|
21
|
-
notify_user(subscription.customer.owner, subscription, Time.zone.at(event.data.object.next_payment_attempt))
|
22
|
-
end
|
23
|
-
|
24
|
-
def notify_user(billable, subscription, date)
|
25
21
|
if Pay.send_emails
|
26
|
-
Pay::UserMailer.with(
|
22
|
+
Pay::UserMailer.with(
|
23
|
+
pay_customer: subscription.customer,
|
24
|
+
subscription: subscription,
|
25
|
+
date: Time.zone.at(event.data.object.next_payment_attempt)
|
26
|
+
).subscription_renewing.deliver_later
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
data/lib/pay/version.rb
CHANGED
data/lib/pay.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: 3.0.
|
4
|
+
version: 3.0.18
|
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: 2021-09-
|
12
|
+
date: 2021-09-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
224
|
- !ruby/object:Gem::Version
|
225
225
|
version: '0'
|
226
226
|
requirements: []
|
227
|
-
rubygems_version: 3.2.
|
227
|
+
rubygems_version: 3.2.22
|
228
228
|
signing_key:
|
229
229
|
specification_version: 4
|
230
230
|
summary: Payments engine for Ruby on Rails
|