pay 3.0.8 → 3.0.12

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: 36bbba4f642300e1894ca803cc17d0f14a59b864fa0d055497ab107f8c37ab6d
4
- data.tar.gz: 28bfdb01793bfdc8dfbcdbd1a266c0c4dca82479273ae2af1ed5316f7b79474c
3
+ metadata.gz: 5a5535971718b3a7b0ea0d09f565dc6a43677209da1700921d202c68639b80d1
4
+ data.tar.gz: 8127f7d2b78d4bfc7cb473dc4ae4f447a311ebe19214a950d7836a67fc244a76
5
5
  SHA512:
6
- metadata.gz: 65e202f12303786496f3d21c630030d8a548f8a122615e832ebf9d7870e2dbd4fe58bac90a98f66809701c7ab154d725852a63bc1cdac44cf61233127104efb3
7
- data.tar.gz: 7dc6eff7449c28fe8322d2a507e080a45e4f960ccf43020de73f75fdd818a7fbf477bac834c1ea815662e4f47a5a055a8adbf2427aaddd8f0d89a926f088511d
6
+ metadata.gz: 4547c7f4ca33877b128c2f5b5e2835c0b3aa80ae6dee8817c64f59428b8e108f0ed611bebad936e0e1b17cd568b505496af7f6ad66cd2dd8897c60d44f5530d1
7
+ data.tar.gz: 022b0d2859f488310bfce2a14eb49796f68a5fece5d906b0228097ce217e00b57316564e339cfd87084d602d06cf30ec10f53eacdbfe8feb10ceefa7d1f68b42
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
@@ -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
@@ -50,9 +50,9 @@ module Pay
50
50
  end
51
51
 
52
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]
53
+ bill_to = [customer.owner.name]
54
+ bill_to += [customer.owner.extra_billing_info] if customer.owner.extra_billing_info?
55
+ bill_to += [nil, customer.owner.email]
56
56
 
57
57
  total = ActionController::Base.helpers.number_to_currency(amount / 100.0)
58
58
 
@@ -175,13 +175,14 @@ 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"],
181
182
  mode: "payment",
182
183
  # These placeholder URLs will be replaced in a following step.
183
- success_url: options.delete(:success_url) || root_url,
184
- cancel_url: options.delete(:cancel_url) || root_url
184
+ success_url: options.delete(:success_url) || root_url(session_id: "{CHECKOUT_SESSION_ID}"),
185
+ cancel_url: options.delete(:cancel_url) || root_url(session_id: "{CHECKOUT_SESSION_ID}")
185
186
  }
186
187
 
187
188
  # Line items are optional
@@ -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.8"
2
+ VERSION = "3.0.12"
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.8
4
+ version: 3.0.12
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-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails