You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: UPGRADE.md
+25-23Lines changed: 25 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,19 @@
1
-
# **Upgrade Guide**
1
+
# Upgrade Guide
2
2
3
3
Follow this guide to upgrade older Pay versions. These may require database migrations and code changes.
4
4
5
-
### ** Pay 7.0 to Pay 8.0**
5
+
## Pay 7.0 to Pay 8.0
6
+
7
+
Pay has moved to using Single Table Inheritance to handle each payment processor's functionality. To do this, we've provided a migration to update the existing records.
6
8
7
9
```bash
8
10
rails pay:install:migrations
9
11
rails db:migrate
10
12
```
11
13
12
-
The `PaymentMethod#type` column has been renamed to `payment_method_type`. If you're displaying payment method details, you'll need to update your views to use the new column name.
14
+
The `PaymentMethod#type` column has been renamed to `payment_method_type` to prevent conflicting with STI. If you're displaying payment method details, you'll need to update your views to use the new column name.
13
15
14
-
## **Pay 6.0 to Pay 7.0**
16
+
## Pay 6.0 to Pay 7.0
15
17
16
18
Pay 7 introduces some changes for Stripe and requires a few additional columns.
17
19
@@ -52,7 +54,7 @@ The secrets/environment variables for Paddle have also been renamed to from `PAD
52
54
53
55
The `paddle_pay` gem requirement has been replaced with `paddle`, which contains APIs for both Paddle Billing and Classic.
54
56
55
-
## **Pay 5.0 to 6.0**
57
+
## Pay 5.0 to 6.0
56
58
This version adds support for accessing the start and end of the current billing period of a subscription. This currently only works with Stripe subscriptions.
57
59
58
60
Fields changed:
@@ -93,11 +95,11 @@ end
93
95
Stripe subscriptions created before this upgrade will gain the `current_period_start` and `current_period_end` attributes the next time they are synced. You can manually sync a Stripe subscription by running `Pay::Stripe::Subscription.sync("STRIPE_SUBSCRIPTION_ID")`
94
96
95
97
96
-
## **Pay 3.0 to 4.0**
98
+
## Pay 3.0 to 4.0
97
99
98
100
This is a major change to add Stripe tax support, Stripe metered billing, new configuration options for payment processors and emails, syncing additional customer attributes to Stripe and Braintree, and improving the architecture of Pay.
99
101
100
-
### **Jump to a topic**
102
+
### Jump to a topic
101
103
-[Method Additions and Changes](#method-additions-and-changes)
In an effort to keep a consistant naming convention, the email parameters of `subscription` and `charge` have been updated to have `pay_` prepended to them (`pay_subscription` and `pay_charge` respectively). If you are directly using any of the built in emails or created custom Pay views, you will want to be sure to update your parameter names to the updated names.
112
114
@@ -126,7 +128,7 @@ The `set_payment_processor` method has a `make_default` optional argument that d
126
128
127
129
Setting the `metadata["pay_name"]` option on a `Stripe::Subscription` object will now set the subscription name if present. Otherwise the `Pay.default_product_name` will be used to set the name.
128
130
129
-
### **Custom Email Sending Configuration**
131
+
### Custom Email Sending Configuration
130
132
131
133
Previously, Pay would send out the following emails based on the value of the `send_emails` configuration variable, which was set to true by default:
132
134
@@ -150,7 +152,7 @@ end
150
152
```
151
153
The above example shows the exact defaults that come pre-configured from Pay. The `config.emails.subscription_renewing` example is specific to Stripe but illustrates how a lambda can be used as a way to evaluate more complex conditions to determine whether an email should be sent. All of these settings can be overridden using the initializer mentioned previously and setting your own values for each email.
152
154
153
-
### **Customer Attributes**
155
+
### Customer Attributes
154
156
155
157
The `pay_customer` macro now accepts options for `stripe_attributes` and `braintree_attributes`. These options can accept a method name or a lambda that returns a hash of `pay_customer` attributes. For example:
156
158
```ruby
@@ -176,23 +178,23 @@ end
176
178
177
179
Being able to send additional customer attributes to Stripe such as the customers address gives you the ability to leverage Stripe's tax support!
178
180
179
-
### **Stripe Tax Support**
181
+
### Stripe Tax Support
180
182
181
183
Using `pay_customer stripe_attributes: :method_name`, you can add an `address` key to `Stripe::Customer` objects which will be used for calculating taxes. `total_tax_amounts` are recorded to `Pay::Charge` records. This includes details for each tax applied to the charge, for example if there are multiple jurisdictions involved. Additionally, when subscribing a customer to a plan the `automatic_tax:` parameter can be enabled as shown here:
Stripe metered billing support removes `quantity` when creating a new subscription (metered billing prices do not allow quantity). Adds `create_usage_record` to `Pay::Subscription` for reporting usage on metered billing plans. The `create_usage_record` method takes a hash of options, see the example below:
To learn more about creating usage records, see [reporting usage](https://stripe.com/docs/products-prices/pricing-models#reporting-usage)
194
196
195
-
### **Enabling Payment Processors**
197
+
### Enabling Payment Processors
196
198
197
199
Previously, all payment processors were enabled by default. With this new release, Pay now allows you to enable any of the payment processors independently. The use case here is that perhaps you already have an implementation in place in your application for one of the processors that we allow integration with and do not want the Pay implementation to conflict. In such a case you can create or add to an initializer at `config/initializers/pay.rb` the following line, including in the array only the process that you wish Pay to setup in your application:
198
200
```ruby
@@ -204,7 +206,7 @@ Pay.setup do |config|
204
206
end
205
207
```
206
208
207
-
### **Supported Dependency Notifications**
209
+
### Supported Dependency Notifications
208
210
209
211
As Pay is working to setup the payment processors that you have enabled it performs a version check on each to ensure that you are using a compatible version.
210
212
@@ -218,11 +220,11 @@ If you are using a non-compatible version Pay will raise an error message to not
218
220
219
221
---
220
222
221
-
## **Pay 2.x to Pay 3.0**
223
+
## Pay 2.x to Pay 3.0
222
224
223
225
This is a major change to add support for multiple payment methods, fixing bugs, and improving the architecture of Pay.
224
226
225
-
### **Jump to a topic**
227
+
### Jump to a topic
226
228
-[Database Migrations](#database-migrations)
227
229
-[Pay::Customer](#paycustomer)
228
230
-[Payment Processor](#payment-processor)
@@ -231,7 +233,7 @@ This is a major change to add support for multiple payment methods, fixing bugs,
231
233
-[Payment Methods](#payment-methods)
232
234
-[Configuration Changes](#configuration-changes)
233
235
234
-
### **Database Migrations**
236
+
### Database Migrations
235
237
236
238
Upgrading from Pay 2.x to 3.0 requires moving data for several things:
237
239
@@ -438,7 +440,7 @@ After running migrations, run the following to sync the customer default payment
438
440
rake pay:payment_methods:sync_default
439
441
```
440
442
441
-
### **Pay::Customer**
443
+
### Pay::Customer
442
444
443
445
The `Pay::Billable` module has been removed and is replaced with `pay_customer` method on your models.
444
446
@@ -465,7 +467,7 @@ user.pay_customers
465
467
#=> Returns all the pay customers associated with this User
466
468
```
467
469
468
-
### **Payment Processor**
470
+
### Payment Processor
469
471
470
472
Instead of calling `@user.charge`, Pay 3 moves the `charge`, `subscribe`, and other methods to the `payment_processor` association. This significantly reduces the methods added to the User model.
0 commit comments