pay 3.0.7 → 3.0.11

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: 278b92c6de6eddff30a1e3ad856ea137b7c020570b89ceb2898396d97b94da8a
4
- data.tar.gz: 28bb9062e581cb49f36b518a5fe47a1dd7ba248e1c868664881687aa5f0932c9
3
+ metadata.gz: 7f81b673f2ce37840c025f8fea1838e0d66625a5bc5d14017a40ed5333268076
4
+ data.tar.gz: '087f55457dc4be6158e9b5ae3a1fa750b62712e906801cfee9a11b2764744aeb'
5
5
  SHA512:
6
- metadata.gz: 2e69eb63bbeb02bf4df7633bee6158b1f5ae21c5606a8807a1a3bc5f39ee9c8d01dae7939583ec00ce6f63d06962ae6b755a4700c14a209ffa4951be17d10015
7
- data.tar.gz: bc5b4888956b0cd12de949cd2ebff34f0808b5e1fdd0e81f499ed7680c185cea911becefb201aefcd90e18fd2b6bc33db2f4f9ea1ecd1b6487dac010efdaa4c2
6
+ metadata.gz: 6d0f622daa0f6698de1b2a7537e0bc85852331c20acace7a3bb7b6730d185dcf5088d47064adb2d0935fcc44d01663da2fb044a526ab0eb22f02bceff227b100
7
+ data.tar.gz: 2a2767806fa3a492a7f87fa11dd9bac57e2be68a776703e4d6560fdd5b24ed837f6aab635110ff3e0147ee29554213f52ba99d53f0b526076a011eb3cc3f5dbd
data/README.md CHANGED
@@ -49,7 +49,7 @@ Want to add a new payment provider? Contributions are welcome.
49
49
  * **Marketplaces**
50
50
  * [Stripe Connect](docs/marketplaces/stripe_connect.md)
51
51
  * **Contributing**
52
- * [Adding A Payment Processor](docs/contributing/adding_a_payment_processor.md)
52
+ * [Adding A Payment Processor](docs/contributing/8_adding_a_payment_processor.md)
53
53
 
54
54
  ## 🙏 Contributing
55
55
 
@@ -10,7 +10,6 @@ module Pay
10
10
  scope :sorted, -> { order(created_at: :desc) }
11
11
  scope :with_active_customer, -> { joins(:customer).merge(Customer.active) }
12
12
  scope :with_deleted_customer, -> { joins(:customer).merge(Customer.deleted) }
13
- default_scope -> { sorted }
14
13
 
15
14
  # Validations
16
15
  validates :amount, presence: true
@@ -4,7 +4,7 @@ module Pay
4
4
 
5
5
  # Associations
6
6
  belongs_to :customer
7
- has_many :charges, class_name: "Pay::Charge", foreign_key: :pay_subscription_id
7
+ has_many :charges
8
8
 
9
9
  # Scopes
10
10
  scope :for_name, ->(name) { where(name: name) }
@@ -135,7 +135,7 @@ module Pay
135
135
  cancel_now!
136
136
  end
137
137
  rescue => e
138
- Rails.logger.info "[Pay] Unable to automatically cancel subscription `#{processor} #{id}`: #{e.message}"
138
+ Rails.logger.info "[Pay] Unable to automatically cancel subscription `#{customer.processor} #{id}`: #{e.message}"
139
139
  end
140
140
  end
141
141
  end
@@ -25,6 +25,13 @@ en:
25
25
  additional_info: Additional Info
26
26
  refunded: Refunded
27
27
  paid: Paid
28
+ invoice:
29
+ amount: "Amount"
30
+ product: "Product"
31
+ quantity: "Quantity"
32
+ subtotal: "Subtotal"
33
+ total: "Total"
34
+ unit_price: "Unit Price"
28
35
  errors:
29
36
  action_required: "This payment attempt failed because additional action is required before it can be completed."
30
37
  invalid_payment: "This payment attempt failed because of an invalid payment method."
@@ -21,7 +21,7 @@ module Pay
21
21
  if saved_change_to_email?
22
22
  # Queue job to update each payment processor for this customer
23
23
  pay_customers.pluck(:id).each do |pay_customer_id|
24
- CustomerSyncJob.perform_later(id)
24
+ CustomerSyncJob.perform_later(pay_customer_id)
25
25
  end
26
26
  end
27
27
  end
@@ -2,7 +2,7 @@ module Pay
2
2
  module Braintree
3
3
  class AuthorizationError < Braintree::Error
4
4
  def message
5
- I18n.t("errors.braintree.authorization")
5
+ I18n.t("pay.errors.braintree.authorization")
6
6
  end
7
7
  end
8
8
  end
data/lib/pay/receipts.rb CHANGED
@@ -16,6 +16,16 @@ module Pay
16
16
  end
17
17
 
18
18
  def receipt_pdf(**options)
19
+ line_items = [
20
+ [I18n.t("pay.receipt.date"), I18n.l(created_at, format: :long)],
21
+ [I18n.t("pay.receipt.account_billed"), "#{customer.customer_name} (#{customer.email})"],
22
+ [I18n.t("pay.receipt.product"), product],
23
+ [I18n.t("pay.receipt.amount"), number_to_currency(amount / 100.0)],
24
+ [I18n.t("pay.receipt.charged_to"), charged_to]
25
+ ]
26
+ line_items << [I18n.t("pay.receipt.additional_info"), customer.owner.extra_billing_info] if customer.owner.extra_billing_info?
27
+ line_items << [I18n.t("pay.receipt.refunded"), number_to_currency(amount_refunded / 100.0)] if refunded?
28
+
19
29
  defaults = {
20
30
  id: id,
21
31
  product: product,
@@ -40,15 +50,25 @@ module Pay
40
50
  end
41
51
 
42
52
  def invoice_pdf(**options)
53
+ bill_to = [owner.name]
54
+ bill_to += [owner.extra_billing_info] if owner.extra_billing_info?
55
+ bill_to += [nil, owner.email]
56
+
57
+ total = ActionController::Base.helpers.number_to_currency(amount / 100.0)
58
+
59
+ line_items = [
60
+ ["<b>#{I18n.t("pay.invoice.product")}</b>", nil, "<b>#{I18n.t("pay.invoice.amount")}</b>"],
61
+ [product, nil, total],
62
+ [nil, I18n.t("pay.invoice.subtotal"), total],
63
+ [nil, I18n.t("pay.invoice.total"), total]
64
+ ]
65
+
43
66
  defaults = {
44
67
  id: id,
45
68
  issue_date: I18n.l(created_at, format: :long),
46
69
  due_date: I18n.l(created_at, format: :long),
47
70
  status: "<b><color rgb='#5eba7d'>#{I18n.t("pay.receipt.paid").upcase}</color></b>",
48
- bill_to: [
49
- customer.customer_name,
50
- customer.email
51
- ].compact,
71
+ bill_to: bill_to,
52
72
  product: product,
53
73
  company: {
54
74
  name: Pay.business_name,
@@ -63,15 +83,6 @@ module Pay
63
83
  end
64
84
 
65
85
  def line_items
66
- line_items = [
67
- [I18n.t("pay.receipt.date"), I18n.l(created_at, format: :long)],
68
- [I18n.t("pay.receipt.account_billed"), "#{customer.customer_name} (#{customer.email})"],
69
- [I18n.t("pay.receipt.product"), product],
70
- [I18n.t("pay.receipt.amount"), number_to_currency(amount / 100.0)],
71
- [I18n.t("pay.receipt.charged_to"), charged_to]
72
- ]
73
- line_items << [I18n.t("pay.receipt.additional_info"), customer.owner.extra_billing_info] if customer.owner.extra_billing_info?
74
- line_items << [I18n.t("pay.receipt.refunded"), number_to_currency(amount_refunded / 100.0)] if refunded?
75
86
  line_items
76
87
  end
77
88
  end
@@ -175,6 +175,7 @@ module Pay
175
175
  # checkout(line_items, "price_12345", allow_promotion_codes: true)
176
176
  #
177
177
  def checkout(**options)
178
+ customer unless processor_id?
178
179
  args = {
179
180
  customer: processor_id,
180
181
  payment_method_types: ["card"],
@@ -203,6 +204,7 @@ module Pay
203
204
  # checkout_charge(amount: 15_00, name: "T-shirt", quantity: 2)
204
205
  #
205
206
  def checkout_charge(amount:, name:, quantity: 1, **options)
207
+ customer unless processor_id?
206
208
  currency = options.delete(:currency) || "usd"
207
209
  checkout(
208
210
  line_items: {
@@ -218,6 +220,7 @@ module Pay
218
220
  end
219
221
 
220
222
  def billing_portal(**options)
223
+ customer unless processor_id?
221
224
  args = {
222
225
  customer: processor_id,
223
226
  return_url: options.delete(:return_url) || root_url
@@ -4,7 +4,7 @@ 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.owner, pay_charge) if pay_charge
7
+ notify_user(pay_charge.customer.owner, pay_charge) if pay_charge
8
8
  end
9
9
 
10
10
  def notify_user(billable, charge)
data/lib/pay/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "3.0.7"
2
+ VERSION = "3.0.11"
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: 3.0.7
4
+ version: 3.0.11
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-05 00:00:00.000000000 Z
12
+ date: 2021-09-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails