pay 4.0.4 → 4.1.0
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/app/models/pay/charge.rb +2 -0
- data/config/locales/en.yml +1 -0
- data/lib/pay/receipts.rb +17 -4
- data/lib/pay/stripe/charge.rb +5 -2
- data/lib/pay/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b424cae3cd4905b55f734e86687c12fba5972aeade9dc81f430d364d29bd9ea6
|
4
|
+
data.tar.gz: 709ca786d171e5b5652fb1a4de5206b2564155a0adabfb02476282eefbfe473a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d153b66802f9ffea402b973ea2420f2cbb9ae6666dfe4c81d49457ac11045c06ee2e54f2ea3410fd5a7b3452461ca580e1cf52cde6831ab9238c624862cbe831
|
7
|
+
data.tar.gz: 2c22450d862a9d39d6abed5b3cc1454c657e15ab92399f64d2c306b69cf600fb2cf838d8d2080d285d42d62b0554de526a72bb7602b342eeecdeff4b49670cbd
|
data/app/models/pay/charge.rb
CHANGED
@@ -41,6 +41,8 @@ module Pay
|
|
41
41
|
store_accessor :data, :discounts # array of discount IDs applied to the Stripe Invoice
|
42
42
|
store_accessor :data, :total_discount_amounts # array of discount details
|
43
43
|
store_accessor :data, :total_tax_amounts # array of tax details for each jurisdiction
|
44
|
+
store_accessor :data, :credit_notes # array of credit notes for the Stripe Invoice
|
45
|
+
store_accessor :data, :refunds # array of refunds
|
44
46
|
|
45
47
|
# Helpers for payment processors
|
46
48
|
%w[braintree stripe paddle fake_processor].each do |processor_name|
|
data/config/locales/en.yml
CHANGED
data/lib/pay/receipts.rb
CHANGED
@@ -86,16 +86,29 @@ module Pay
|
|
86
86
|
"#{tax_rate["display_name"]} - #{tax_rate["jurisdiction"]} (#{percent})"
|
87
87
|
end
|
88
88
|
|
89
|
-
def
|
90
|
-
|
89
|
+
def receipt_line_items
|
90
|
+
line_items = pdf_line_items
|
91
91
|
|
92
92
|
# Include total paid
|
93
|
-
|
93
|
+
line_items << [nil, nil, I18n.t("pay.receipt.amount_paid"), Pay::Currency.format(amount, currency: currency)]
|
94
94
|
|
95
95
|
if refunded?
|
96
|
-
|
96
|
+
# If we have a list of individual refunds, add each entry
|
97
|
+
if refunds&.any?
|
98
|
+
refunds.each do |refund|
|
99
|
+
next unless refund["status"] == "succeeded"
|
100
|
+
refunded_at = Time.at(refund["created"]).to_date
|
101
|
+
line_items << [nil, nil, I18n.t("pay.receipt.refunded_on", date: I18n.l(refunded_at, format: :long)), Pay::Currency.format(refund["amount"], currency: refund["currency"])]
|
102
|
+
end
|
103
|
+
else
|
104
|
+
line_items << [nil, nil, I18n.t("pay.receipt.refunded"), Pay::Currency.format(amount_refunded, currency: currency)]
|
105
|
+
end
|
97
106
|
end
|
98
107
|
|
108
|
+
line_items
|
109
|
+
end
|
110
|
+
|
111
|
+
def receipt_pdf(**options)
|
99
112
|
defaults = {
|
100
113
|
details: receipt_details,
|
101
114
|
recipient: [
|
data/lib/pay/stripe/charge.rb
CHANGED
@@ -22,6 +22,9 @@ module Pay
|
|
22
22
|
pay_customer = Pay::Customer.find_by(processor: :stripe, processor_id: object.customer)
|
23
23
|
return unless pay_customer
|
24
24
|
|
25
|
+
refunds = []
|
26
|
+
object.refunds.auto_paging_each { |refund| refunds << refund }
|
27
|
+
|
25
28
|
payment_method = object.payment_method_details.send(object.payment_method_details.type)
|
26
29
|
attrs = {
|
27
30
|
amount: object.amount,
|
@@ -42,7 +45,8 @@ module Pay
|
|
42
45
|
payment_method_type: object.payment_method_details.type,
|
43
46
|
stripe_account: pay_customer.stripe_account,
|
44
47
|
stripe_receipt_url: object.receipt_url,
|
45
|
-
total_tax_amounts: []
|
48
|
+
total_tax_amounts: [],
|
49
|
+
refunds: refunds.sort_by! { |r| r["created"] }
|
46
50
|
}
|
47
51
|
|
48
52
|
# Associate charge with subscription if we can
|
@@ -75,7 +79,6 @@ module Pay
|
|
75
79
|
period_end: Time.at(line_item.period.end)
|
76
80
|
}
|
77
81
|
end
|
78
|
-
|
79
82
|
# Charges without invoices
|
80
83
|
else
|
81
84
|
attrs[:period_start] = Time.at(object.created)
|
data/lib/pay/version.rb
CHANGED