pay 2.0.2 → 2.0.3

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: 1005b0ddaa3f5c9f23ab4b6b81620b261331445fc1d3c865240351490d6d897f
4
- data.tar.gz: 16531ff0cf034283445a6ce27ed950166f366db58fc89f152e9482b0385fa20c
3
+ metadata.gz: 300877c7b5a4a24f3796a7fe32c6deff0c2851a9a43d2c30ea86b69892384865
4
+ data.tar.gz: 6c6a7b986a3fe4fd2731dcf21ee9d3adb1a4fb05f6cc07060b51a0aa50566459
5
5
  SHA512:
6
- metadata.gz: 44f3034d0afca7fe1bf8f2bb657a573fc4fd93376a24106d1f7f7872215fd6e35f7b3a4ce5e67f5a62355445f19f3edda55bd4a43c9d289f654c42088f10602a
7
- data.tar.gz: 3f14506cdbf220dd09ef1b3d1a72008f50e0963208e24807bad8382725c0c74ff8f4f06f02b18f84a43036d362c6a180d934c51d1664c6c3df91e0efce50bdd6
6
+ metadata.gz: 2b0b709fb6e3a3f51b3f74774908775af8a9ef3ab71ca8b2981c9fc010ede85cf0b71d779659e0e3dfb185ba20dcc16d90b71140992bc5e7241711be9334add2
7
+ data.tar.gz: e22547e8e914cb70cc75d95bfd8414d1c5ca203e2cc7a8717416296c538b2123762499841b34aff655d74d7c7548a71d3f5de9f467af91acf6ee36d223f3b7d1
data/README.md CHANGED
@@ -20,7 +20,7 @@ Want to add a new payment provider? Contributions are welcome and the instructio
20
20
  Add these lines to your application's Gemfile:
21
21
 
22
22
  ```ruby
23
- gem 'pay'
23
+ gem 'pay', '~> 2.0'
24
24
 
25
25
  # To use Stripe, also include:
26
26
  gem 'stripe', '< 6.0', '>= 2.8'
@@ -30,7 +30,7 @@ gem 'stripe_event', '~> 2.3'
30
30
  gem 'braintree', '< 3.0', '>= 2.92.0'
31
31
 
32
32
  # To use Receipts
33
- gem 'receipts', '~> 0.2.2'
33
+ gem 'receipts', '~> 1.0.0'
34
34
  ```
35
35
 
36
36
  And then execute:
@@ -100,6 +100,17 @@ you plan on doing more complex payments. It would be best to stick with
100
100
  a single payment provider in that case so you don't run into
101
101
  discrepancies.
102
102
 
103
+ #### Braintree
104
+
105
+ ```yaml
106
+ development:
107
+ braintree:
108
+ private_key: xxxx
109
+ public_key: yyyy
110
+ merchant_id: zzzz
111
+ environment: sandbox
112
+ ```
113
+
103
114
  #### Stripe
104
115
 
105
116
  You'll need to add your private Stripe API key to your Rails secrets `config/secrets.yml`, credentials `rails credentials:edit`
@@ -132,6 +143,10 @@ stripe listen --forward-to localhost:3000/pay/webhooks/stripe
132
143
 
133
144
  You should use `stripe.handleCardSetup` on the client to collect card information anytime you want to save the card and charge them later (adding a card, then charging them on the next page for example). Use `stripe.handleCardPayment` if you'd like to charge the customer immediately (think checking out of a shopping cart).
134
145
 
146
+ The Javascript will now need to use createPaymentMethod instead of createToken. https://stripe.com/docs/js/payment_intents/create_payment_method
147
+
148
+ The Javascript also needs to have a PaymentIntent or SetupIntent created server-side and the ID passed into the Javascript to do this. That way it knows how to safely handle the card tokenization if it meets the SCA requirements.
149
+
135
150
  **Payment Confirmations**
136
151
 
137
152
  Sometimes you'll have a payment that requires extra authentication. In this case, Pay provides a webhook and action for handling these payments. It will automatically email the customer and provide a link with the PaymentIntent ID in the url where the customer will be asked to fill out their name and card number to confirm the payment. Once done, they'll be redirected back to your application.
@@ -179,8 +194,8 @@ Pay.setup do |config|
179
194
 
180
195
  config.send_emails = true
181
196
 
182
- config.automount_webhook_routes = true
183
- config.routes_path = "/pay" # Only when automount_webhook_routes is true
197
+ config.automount_routes = true
198
+ config.routes_path = "/pay" # Only when automount_routes is true
184
199
  end
185
200
  ```
186
201
 
@@ -211,9 +226,12 @@ development:
211
226
  braintree:
212
227
  private_key: xxxx
213
228
  public_key: yyyy
229
+ merchant_id: aaaa
230
+ environment: sandbox
214
231
  ```
215
232
 
216
- You can also use the `STRIPE_PUBLIC_KEY`, `STRIPE_PRIVATE_KEY` and `STRIPE_SIGNING_SECRET` environment variables.
233
+ For Stripe, you can also use the `STRIPE_PUBLIC_KEY`, `STRIPE_PRIVATE_KEY` and `STRIPE_SIGNING_SECRET` environment variables.
234
+ For Braintree, you can also use `BRAINTREE_MERCHANT_ID`, `BRAINTREE_PUBLIC_KEY`, `BRAINTREE_PRIVATE_KEY`, and `BRAINTREE_ENVIRONMENT` environment variables.
217
235
 
218
236
  ### Generators
219
237
 
@@ -17,9 +17,9 @@ module Pay
17
17
 
18
18
  # Scopes
19
19
  scope :for_name, ->(name) { where(name: name) }
20
- scope :on_trial, -> { where.not(trial_ends_at: nil).where("trial_ends_at > ?", Time.zone.now) }
20
+ scope :on_trial, -> { where.not(trial_ends_at: nil).where("#{table_name}.trial_ends_at > ?", Time.zone.now) }
21
21
  scope :cancelled, -> { where.not(ends_at: nil) }
22
- scope :on_grace_period, -> { cancelled.where("ends_at > ?", Time.zone.now) }
22
+ scope :on_grace_period, -> { cancelled.where("#{table_name}.ends_at > ?", Time.zone.now) }
23
23
  scope :active, -> { where(ends_at: nil).or(on_grace_period).or(on_trial) }
24
24
  scope :incomplete, -> { where(status: :incomplete) }
25
25
  scope :past_due, -> { where(status: :past_due) }
@@ -82,7 +82,7 @@ module Pay
82
82
 
83
83
  send("#{processor}_resume")
84
84
 
85
- update(ends_at: nil)
85
+ update(ends_at: nil, status: "active")
86
86
  self
87
87
  end
88
88
 
@@ -1,4 +1,4 @@
1
- class CreatePayCharges < ActiveRecord::Migration[5.1]
1
+ class CreatePayCharges < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :pay_charges do |t|
4
4
  t.references :owner
@@ -1,4 +1,4 @@
1
- class AddStatusToPaySubscriptions < ActiveRecord::Migration[5.2]
1
+ class AddStatusToPaySubscriptions < ActiveRecord::Migration[4.2]
2
2
  def self.up
3
3
  add_column :pay_subscriptions, :status, :string
4
4
 
@@ -13,10 +13,10 @@ module Pay
13
13
  # 3. Check unscoped credentials, then secrets
14
14
  def find_value_by_name(scope, name)
15
15
  ENV["#{scope.upcase}_#{name.upcase}"] ||
16
- credentials.dig(env, scope, name) ||
17
- secrets.dig(env, scope, name) ||
18
- credentials.dig(scope, name) ||
19
- secrets.dig(scope, name)
16
+ credentials&.dig(env, scope, name) ||
17
+ secrets&.dig(env, scope, name) ||
18
+ credentials&.dig(scope, name) ||
19
+ secrets&.dig(scope, name)
20
20
  end
21
21
 
22
22
  def env
@@ -28,7 +28,7 @@ module Pay
28
28
  end
29
29
 
30
30
  def credentials
31
- Rails.application.credentials
31
+ Rails.application.credentials if Rails.application.respond_to?(:credentials)
32
32
  end
33
33
  end
34
34
  end
@@ -139,8 +139,8 @@ module Pay
139
139
 
140
140
  # Update the user's card on file if a token was passed in
141
141
  if card_token.present?
142
- ::Stripe::PaymentMethod.attach(card_token, {customer: customer.id})
143
- customer.invoice_settings.default_payment_method = card_token
142
+ payment_method = ::Stripe::PaymentMethod.attach(card_token, {customer: customer.id})
143
+ customer.invoice_settings.default_payment_method = payment_method.id
144
144
  customer.save
145
145
 
146
146
  update_stripe_card_on_file ::Stripe::PaymentMethod.retrieve(card_token).card
@@ -11,7 +11,7 @@ module Pay
11
11
  subscription.save
12
12
 
13
13
  new_ends_at = on_trial? ? trial_ends_at : Time.at(subscription.current_period_end)
14
- update(ends_at: new_ends_at, status: :canceled)
14
+ update(ends_at: new_ends_at)
15
15
  rescue ::Stripe::StripeError => e
16
16
  raise Error, e.message
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "2.0.2"
2
+ VERSION = "2.0.3"
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: 2.0.2
4
+ version: 2.0.3
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: 2020-02-13 00:00:00.000000000 Z
12
+ date: 2020-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -284,7 +284,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
284
  - !ruby/object:Gem::Version
285
285
  version: '0'
286
286
  requirements: []
287
- rubygems_version: 3.1.2
287
+ rubygems_version: 3.0.3
288
288
  signing_key:
289
289
  specification_version: 4
290
290
  summary: A Ruby on Rails subscription engine.