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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6659a95f47cd229375f090cb734b440ca8484cd9672b88bd482dede070fa6819
4
- data.tar.gz: 408ef1cbfd3364d30d7e7bbfd78c58b585034c54e65346db92f1e9a7cf3ab279
3
+ metadata.gz: b424cae3cd4905b55f734e86687c12fba5972aeade9dc81f430d364d29bd9ea6
4
+ data.tar.gz: 709ca786d171e5b5652fb1a4de5206b2564155a0adabfb02476282eefbfe473a
5
5
  SHA512:
6
- metadata.gz: 8ffbc4d1d685f994a1dc3e45d8b7f20a4a4d4f8852cd3ca7d349d2af5cc22445c2c526eef8906305aa80b8d37ae82c6f0101b271a121b66d4bc4624f82446480
7
- data.tar.gz: 12332883526b3e321e70e8b30445b40dfa85715f3a7a7bfece32940fb857f8f747b586d48245f760b9e3866a54d2532d9ca9dce8b0da55441f3b619cec14072f
6
+ metadata.gz: d153b66802f9ffea402b973ea2420f2cbb9ae6666dfe4c81d49457ac11045c06ee2e54f2ea3410fd5a7b3452461ca580e1cf52cde6831ab9238c624862cbe831
7
+ data.tar.gz: 2c22450d862a9d39d6abed5b3cc1454c657e15ab92399f64d2c306b69cf600fb2cf838d8d2080d285d42d62b0554de526a72bb7602b342eeecdeff4b49670cbd
@@ -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|
@@ -35,6 +35,7 @@ en:
35
35
  payment_method: "Payment Method"
36
36
  amount_paid: "Amount paid"
37
37
  refunded: "Refunded"
38
+ refunded_on: "Refunded on %{date}"
38
39
  invoice:
39
40
  number: "Invoice Number"
40
41
  date: "Date"
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 receipt_pdf(**options)
90
- receipt_line_items = pdf_line_items
89
+ def receipt_line_items
90
+ line_items = pdf_line_items
91
91
 
92
92
  # Include total paid
93
- receipt_line_items << [nil, nil, I18n.t("pay.receipt.amount_paid"), Pay::Currency.format(amount, currency: currency)]
93
+ line_items << [nil, nil, I18n.t("pay.receipt.amount_paid"), Pay::Currency.format(amount, currency: currency)]
94
94
 
95
95
  if refunded?
96
- receipt_line_items << [nil, nil, I18n.t("pay.receipt.refunded_on"), Pay::Currency.format(amount_refunded, currency: currency)]
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: [
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "4.0.4"
2
+ VERSION = "4.1.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: 4.0.4
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes