Skip to content

Commit 8c49d54

Browse files
committed
Update upgrade guide
1 parent 95843ce commit 8c49d54

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

UPGRADE.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
# **Upgrade Guide**
1+
# Upgrade Guide
22

33
Follow this guide to upgrade older Pay versions. These may require database migrations and code changes.
44

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.
68

79
```bash
810
rails pay:install:migrations
911
rails db:migrate
1012
```
1113

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.
1315

14-
## **Pay 6.0 to Pay 7.0**
16+
## Pay 6.0 to Pay 7.0
1517

1618
Pay 7 introduces some changes for Stripe and requires a few additional columns.
1719

@@ -52,7 +54,7 @@ The secrets/environment variables for Paddle have also been renamed to from `PAD
5254

5355
The `paddle_pay` gem requirement has been replaced with `paddle`, which contains APIs for both Paddle Billing and Classic.
5456

55-
## **Pay 5.0 to 6.0**
57+
## Pay 5.0 to 6.0
5658
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.
5759

5860
Fields changed:
@@ -93,11 +95,11 @@ end
9395
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")`
9496

9597

96-
## **Pay 3.0 to 4.0**
98+
## Pay 3.0 to 4.0
9799

98100
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.
99101

100-
### **Jump to a topic**
102+
### Jump to a topic
101103
- [Method Additions and Changes](#method-additions-and-changes)
102104
- [Custom Email Sending Configuration](#custom-email-sending-configuration)
103105
- [Customer Attributes](#customer-attributes)
@@ -106,7 +108,7 @@ This is a major change to add Stripe tax support, Stripe metered billing, new co
106108
- [Enabling Payment Processors](#enabling-payment-processors)
107109
- [Supported Dependency Notifications](#supported-dependency-notifications)
108110

109-
### **Method Additions and Changes**
111+
### Method Additions and Changes
110112

111113
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.
112114

@@ -126,7 +128,7 @@ The `set_payment_processor` method has a `make_default` optional argument that d
126128

127129
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.
128130

129-
### **Custom Email Sending Configuration**
131+
### Custom Email Sending Configuration
130132

131133
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:
132134

@@ -150,7 +152,7 @@ end
150152
```
151153
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.
152154

153-
### **Customer Attributes**
155+
### Customer Attributes
154156

155157
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:
156158
```ruby
@@ -176,23 +178,23 @@ end
176178

177179
Being able to send additional customer attributes to Stripe such as the customers address gives you the ability to leverage Stripe's tax support!
178180

179-
### **Stripe Tax Support**
181+
### Stripe Tax Support
180182

181183
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:
182184

183185
```ruby
184186
@user.payment_processor.subscribe(plan: "growth", automatic_tax: { enabled: true })
185187
```
186188

187-
### **Stripe Metered Billing Support**
189+
### Stripe Metered Billing Support
188190

189191
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:
190192
```ruby
191193
create_usage_record(subscription_item_id: "si_1234", quantity: 100, action: :set)
192194
```
193195
To learn more about creating usage records, see [reporting usage](https://stripe.com/docs/products-prices/pricing-models#reporting-usage)
194196

195-
### **Enabling Payment Processors**
197+
### Enabling Payment Processors
196198

197199
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:
198200
```ruby
@@ -204,7 +206,7 @@ Pay.setup do |config|
204206
end
205207
```
206208

207-
### **Supported Dependency Notifications**
209+
### Supported Dependency Notifications
208210

209211
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.
210212

@@ -218,11 +220,11 @@ If you are using a non-compatible version Pay will raise an error message to not
218220

219221
---
220222

221-
## **Pay 2.x to Pay 3.0**
223+
## Pay 2.x to Pay 3.0
222224

223225
This is a major change to add support for multiple payment methods, fixing bugs, and improving the architecture of Pay.
224226

225-
### **Jump to a topic**
227+
### Jump to a topic
226228
- [Database Migrations](#database-migrations)
227229
- [Pay::Customer](#paycustomer)
228230
- [Payment Processor](#payment-processor)
@@ -231,7 +233,7 @@ This is a major change to add support for multiple payment methods, fixing bugs,
231233
- [Payment Methods](#payment-methods)
232234
- [Configuration Changes](#configuration-changes)
233235

234-
### **Database Migrations**
236+
### Database Migrations
235237

236238
Upgrading from Pay 2.x to 3.0 requires moving data for several things:
237239

@@ -438,7 +440,7 @@ After running migrations, run the following to sync the customer default payment
438440
rake pay:payment_methods:sync_default
439441
```
440442

441-
### **Pay::Customer**
443+
### Pay::Customer
442444

443445
The `Pay::Billable` module has been removed and is replaced with `pay_customer` method on your models.
444446

@@ -465,7 +467,7 @@ user.pay_customers
465467
#=> Returns all the pay customers associated with this User
466468
```
467469

468-
### **Payment Processor**
470+
### Payment Processor
469471

470472
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.
471473

@@ -486,7 +488,7 @@ user.payment_processor.subscribe(plan: "whatever")
486488
# Creates Pay::Subscription record for the subscription
487489
```
488490

489-
### **Generic Trials**
491+
### Generic Trials
490492

491493
Generic trials are now done using the fake payment processor
492494

@@ -496,11 +498,11 @@ user.payment_processor.subscribe(trial_ends_at: 14.days.from_now, ends_at: 14.da
496498
user.payment_processor.on_trial? #=> true
497499
```
498500

499-
### **Charges & Subscriptions**
501+
### Charges & Subscriptions
500502

501503
`Pay::Charge` and `Pay::Subscription` are associated `Pay::Customer` and no longer directly connected to the `owner`
502504

503-
### **Payment Methods**
505+
### Payment Methods
504506

505507
Pay 3 now keeps track of multiple payment methods. Each is associated with a Pay::Customer and one is marked as the default.
506508

@@ -517,7 +519,7 @@ charge.payment_method_type #=> "paypal"
517519
charge.email #=> "[email protected]"
518520
```
519521

520-
### **Configuration Changes**
522+
### Configuration Changes
521523

522524
We've removed several configuration options since Pay 3+ will always use the models from the gem for charges, subscriptions, etc.
523525

0 commit comments

Comments
 (0)