pay 3.0.23 → 3.0.24

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: 5755d6421fc4b0366728f278b32de2f9f1bf6186cafe4c62cf9c5a188204d0d6
4
- data.tar.gz: 5a4cf13ffbdf85017401dd9aca4ddc3d7fd48fea249868ff10c04bfa383e39d1
3
+ metadata.gz: 5b3ebc48aeb54c0c71ccb8570c00ca5194258982fc06f00a51e2b49211dd82f0
4
+ data.tar.gz: f13ea4e812837ce733f797b9165ad798a0920e80e95b201a26a83c12c5c91f1f
5
5
  SHA512:
6
- metadata.gz: 966be7e8c643bb6bfa65f21d111d76e35d461a500630434f6b37907c9001f823ae3aa7193f763a7b0af76ef35806de91bd8acfaff1eef219972c8284a96835d3
7
- data.tar.gz: b0dd861df1aa7cb64ab45b267de205251e4a8885a113219a0eb5c3d4fe087332fae129ca7fa1b619d7b75aef6a53698f1665d977c52a472a3d31bce90ff255d5
6
+ metadata.gz: 44a72ba1d1c77004f2e98a20a0a6014030614be04027b6f2341d58523af3fb686bcef8ebdbde9233f52fc65c7578863430b60e2a0a73feadcf79d95043a94c38
7
+ data.tar.gz: acf91b1679dabc86e8199a28b5fd87a72a18362c8436dac3fc3318b624896bbce92b6936f8694250e4a46ca84c03defe3209e1d074273abae87fe96fcef4b448
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # 💳 Pay - Payments engine for Ruby on Rails
4
4
 
5
- [![Build Status](https://github.com/pay-rails/pay/workflows/Tests/badge.svg)](https://github.com/pay-rails/pay/actions) [![Gem Version](https://badge.fury.io/rb/pay.svg)](https://badge.fury.io/rb/pay)
5
+ [![Build Status](https://github.com/pay-rails/pay/workflows/Tests/badge.svg)](https://github.com/pay-rails/pay/actions) [![Gem Version](https://badge.fury.io/rb/pay.svg)](https://badge.fury.io/rb/pay) [![Tuple](https://img.shields.io/badge/Pairing%20with-Tuple-5A67D8)](https://tuple.app)
6
6
 
7
7
  <img src="docs/images/stripe_partner_badge.svg" height="26px">
8
8
 
@@ -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/8_adding_a_payment_processor.md)
52
+ * [Adding A Payment Processor](docs/contributing/adding_a_payment_processor.md)
53
53
 
54
54
  ## 🙏 Contributing
55
55
 
@@ -5,7 +5,7 @@ module Pay
5
5
  def perform(pay_customer_id)
6
6
  Pay::Customer.find(pay_customer_id).update_customer!
7
7
  rescue ActiveRecord::RecordNotFound
8
- Rails.logger.info "Couldn't find a Pay::Customer with ID = #{id}"
8
+ Rails.logger.info "Couldn't find a Pay::Customer with ID = #{pay_customer_id}"
9
9
  end
10
10
  end
11
11
  end
@@ -31,8 +31,8 @@ module Pay
31
31
  processor_id: NanoId.generate,
32
32
  amount: amount,
33
33
  data: {
34
- kind: :card,
35
- type: :fake,
34
+ payment_method_type: :card,
35
+ brand: "Fake",
36
36
  last4: 1234,
37
37
  exp_month: Date.today.month,
38
38
  exp_year: Date.today.year
@@ -44,7 +44,6 @@ module Pay
44
44
  def subscribe(name: Pay.default_product_name, plan: Pay.default_plan_name, **options)
45
45
  # Make to generate a processor_id
46
46
  customer
47
-
48
47
  attributes = options.merge(
49
48
  processor_id: NanoId.generate,
50
49
  name: name,
@@ -52,6 +51,11 @@ module Pay
52
51
  status: :active,
53
52
  quantity: options.fetch(:quantity, 1)
54
53
  )
54
+
55
+ if (trial_period_days = attributes.delete(:trial_period_days))
56
+ attributes[:trial_ends_at] = trial_period_days.to_i.days.from_now
57
+ end
58
+
55
59
  pay_customer.subscriptions.create!(attributes)
56
60
  end
57
61
 
@@ -59,10 +63,10 @@ module Pay
59
63
  # Make to generate a processor_id
60
64
  customer
61
65
 
62
- pay_customer.payment_methods.create!(
66
+ pay_payment_method = pay_customer.payment_methods.create!(
63
67
  processor_id: NanoId.generate,
64
68
  default: default,
65
- type: :fake,
69
+ type: :card,
66
70
  data: {
67
71
  brand: "Fake",
68
72
  last4: 1234,
@@ -70,6 +74,9 @@ module Pay
70
74
  exp_year: Date.today.year
71
75
  }
72
76
  )
77
+
78
+ pay_customer.reload_default_payment_method if default
79
+ pay_payment_method
73
80
  end
74
81
 
75
82
  def update_email!
@@ -57,6 +57,9 @@ module Pay
57
57
 
58
58
  def swap(plan)
59
59
  end
60
+
61
+ def change_quantity(quantity)
62
+ end
60
63
  end
61
64
  end
62
65
  end
@@ -177,8 +177,8 @@ module Pay
177
177
  # checkout(mode: "subscription")
178
178
  #
179
179
  # checkout(line_items: "price_12345", quantity: 2)
180
- # checkout(line_items [{ price: "price_123" }, { price: "price_456" }])
181
- # checkout(line_items, "price_12345", allow_promotion_codes: true)
180
+ # checkout(line_items: [{ price: "price_123" }, { price: "price_456" }])
181
+ # checkout(line_items: "price_12345", allow_promotion_codes: true)
182
182
  #
183
183
  def checkout(**options)
184
184
  customer unless processor_id?
@@ -193,11 +193,16 @@ module Pay
193
193
 
194
194
  # Line items are optional
195
195
  if (line_items = options.delete(:line_items))
196
+ quantity = options.delete(:quantity) || 1
197
+
196
198
  args[:line_items] = Array.wrap(line_items).map { |item|
197
199
  if item.is_a? Hash
198
200
  item
199
201
  else
200
- {price: item, quantity: options.fetch(:quantity, 1)}
202
+ {
203
+ price: item,
204
+ quantity: quantity
205
+ }
201
206
  end
202
207
  }
203
208
  end
data/lib/pay/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "3.0.23"
2
+ VERSION = "3.0.24"
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.23
4
+ version: 3.0.24
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-10-07 00:00:00.000000000 Z
12
+ date: 2021-12-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails