paddle_rails 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +37 -13
- data/app/assets/stylesheets/paddle_rails/tailwind.css +288 -238
- data/app/controllers/concerns/paddle_rails/paddle_checkout_error_handler.rb +0 -1
- data/app/controllers/concerns/paddle_rails/subscription_owner.rb +0 -1
- data/app/controllers/paddle_rails/application_controller.rb +1 -1
- data/app/controllers/paddle_rails/checkout_controller.rb +5 -6
- data/app/controllers/paddle_rails/dashboard_controller.rb +12 -11
- data/app/controllers/paddle_rails/onboarding_controller.rb +4 -11
- data/app/controllers/paddle_rails/payments_controller.rb +0 -1
- data/app/controllers/paddle_rails/subscriptions_controller.rb +2 -2
- data/app/controllers/paddle_rails/webhooks_controller.rb +0 -1
- data/app/helpers/paddle_rails/application_helper.rb +9 -9
- data/app/helpers/paddle_rails/subscription_owner_helper.rb +0 -1
- data/app/jobs/paddle_rails/process_webhook_job.rb +0 -1
- data/app/models/concerns/paddle_rails/subscribable.rb +6 -1
- data/app/models/paddle_rails/payment.rb +0 -1
- data/app/models/paddle_rails/price.rb +0 -1
- data/app/models/paddle_rails/product.rb +6 -1
- data/app/models/paddle_rails/subscription.rb +5 -3
- data/app/models/paddle_rails/subscription_item.rb +0 -1
- data/app/models/paddle_rails/webhook_event.rb +1 -2
- data/app/presenters/paddle_rails/payment_presenter.rb +4 -2
- data/app/presenters/paddle_rails/pricing_plan_presenter.rb +153 -0
- data/app/presenters/paddle_rails/product_presenter.rb +13 -2
- data/app/presenters/paddle_rails/subscription_presenter.rb +9 -10
- data/app/views/layouts/paddle_rails/application.html.erb +36 -137
- data/app/views/paddle_rails/dashboard/_change_plan.html.erb +36 -42
- data/app/views/paddle_rails/dashboard/show.html.erb +18 -6
- data/app/views/paddle_rails/onboarding/show.html.erb +96 -71
- data/app/views/paddle_rails/shared/_pricing_plans_required.html.erb +14 -0
- data/db/migrate/20251124000000_create_paddle_rails_tables.rb +97 -0
- data/lib/generators/paddle_rails/install/install_generator.rb +38 -0
- data/lib/generators/paddle_rails/install/templates/initializer.rb +24 -0
- data/lib/paddle_rails/checkout.rb +1 -3
- data/lib/paddle_rails/configuration.rb +4 -5
- data/lib/paddle_rails/engine.rb +16 -3
- data/lib/paddle_rails/plan.rb +187 -0
- data/lib/paddle_rails/product_sync.rb +14 -15
- data/lib/paddle_rails/subscription_sync.rb +30 -31
- data/lib/paddle_rails/version.rb +1 -1
- data/lib/paddle_rails/webhook_processor.rb +3 -4
- data/lib/paddle_rails/webhook_verifier.rb +1 -2
- data/lib/paddle_rails.rb +4 -0
- metadata +7 -19
- data/db/migrate/20251124180624_create_paddle_rails_subscription_plans.rb +0 -18
- data/db/migrate/20251124180817_create_paddle_rails_subscription_prices.rb +0 -26
- data/db/migrate/20251127221947_create_paddle_rails_webhook_events.rb +0 -19
- data/db/migrate/20251128135831_create_paddle_rails_subscriptions.rb +0 -21
- data/db/migrate/20251128142327_create_paddle_rails_subscription_items.rb +0 -16
- data/db/migrate/20251128151334_remove_paddle_price_id_from_subscriptions.rb +0 -7
- data/db/migrate/20251128151401_rename_subscription_plans_to_products.rb +0 -6
- data/db/migrate/20251128151402_rename_subscription_plan_id_to_subscription_product_id.rb +0 -13
- data/db/migrate/20251128151453_remove_subscription_price_id_from_subscriptions.rb +0 -8
- data/db/migrate/20251128151501_add_subscription_product_id_to_subscription_items.rb +0 -8
- data/db/migrate/20251128152025_remove_paddle_item_id_from_subscription_items.rb +0 -6
- data/db/migrate/20251128212046_rename_subscription_products_to_products.rb +0 -6
- data/db/migrate/20251128212047_rename_subscription_prices_to_prices.rb +0 -6
- data/db/migrate/20251128212053_rename_subscription_product_id_to_product_id_in_prices.rb +0 -13
- data/db/migrate/20251128212054_rename_fks_in_subscription_items.rb +0 -20
- data/db/migrate/20251128220016_add_scheduled_cancelation_at_to_subscriptions.rb +0 -6
- data/db/migrate/20251129121336_add_payment_method_to_subscriptions.rb +0 -10
- data/db/migrate/20251129222345_create_paddle_rails_payments.rb +0 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4cbe24ab68c00936c543e5688bf224bb8b0b861997bea786a2b074aa6c8d9a66
|
|
4
|
+
data.tar.gz: 1bce594d47a17288fae08c785fcc60dcdce5cd294a8ae9f6c609fc7f0ea07caa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1d8050efe17de87fa937aec3087541f33c7739ff1116d88e0b0cf4c8868d3918b3340b1d3319235ce4a3ceab92738b52fe8e908fe97997b36a21c0164ed1e728
|
|
7
|
+
data.tar.gz: 41426d179a13fc3162923acdce3ef4e19ab4dde783efc3b34aa4e94157e3332fd99b754c0f13fa967b9bd057dd9f1538bf45a40156264e1a16000eabb220ee7f
|
data/README.md
CHANGED
|
@@ -33,17 +33,16 @@ gem "paddle_rails"
|
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
35
|
$ bundle install
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Install the migrations to create the necessary tables:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
$ bin/rails paddle_rails:install:migrations
|
|
36
|
+
$ bin/rails generate paddle_rails:install
|
|
42
37
|
$ bin/rails db:migrate
|
|
43
38
|
```
|
|
44
39
|
|
|
45
40
|
### 2. Configure Paddle credentials
|
|
46
41
|
|
|
42
|
+
PaddleRails looks for credentials in this order: **environment variables → Rails credentials → nil**. You only need to configure one source.
|
|
43
|
+
|
|
44
|
+
**Option A: Environment variables** (recommended for containers, CI, local dev with dotenv)
|
|
45
|
+
|
|
47
46
|
```bash
|
|
48
47
|
# .env or environment variables
|
|
49
48
|
PADDLE_API_KEY=your_api_key
|
|
@@ -52,6 +51,20 @@ PADDLE_ENVIRONMENT=sandbox # or "production"
|
|
|
52
51
|
PADDLE_WEBHOOK_SECRET=your_webhook_secret
|
|
53
52
|
```
|
|
54
53
|
|
|
54
|
+
**Option B: Rails credentials** (recommended for production secrets)
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
$ bin/rails credentials:edit
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```yaml
|
|
61
|
+
paddle:
|
|
62
|
+
api_key: your_api_key
|
|
63
|
+
public_token: your_public_token
|
|
64
|
+
environment: sandbox
|
|
65
|
+
webhook_secret: your_webhook_secret
|
|
66
|
+
```
|
|
67
|
+
|
|
55
68
|
### 3. Mount the billing portal
|
|
56
69
|
|
|
57
70
|
Add this to your `config/routes.rb`:
|
|
@@ -119,20 +132,22 @@ The billing portal is designed to be clean and professional out of the box. It u
|
|
|
119
132
|
|
|
120
133
|
## Configuration
|
|
121
134
|
|
|
135
|
+
Credentials are automatically loaded from environment variables or Rails credentials (see [Quick Start](#2-configure-paddle-credentials)). You only need an initializer if you want to override defaults or customize the authenticator:
|
|
136
|
+
|
|
122
137
|
```ruby
|
|
123
138
|
# config/initializers/paddle_rails.rb
|
|
124
139
|
PaddleRails.configure do |config|
|
|
125
|
-
#
|
|
126
|
-
config.api_key =
|
|
127
|
-
config.public_token =
|
|
128
|
-
config.environment =
|
|
129
|
-
config.webhook_secret =
|
|
130
|
-
|
|
140
|
+
# Override credentials (optional — env vars and Rails credentials are used by default)
|
|
141
|
+
# config.api_key = "your_api_key"
|
|
142
|
+
# config.public_token = "your_public_token"
|
|
143
|
+
# config.environment = "sandbox" # or "production" (defaults to "sandbox")
|
|
144
|
+
# config.webhook_secret = "your_webhook_secret"
|
|
145
|
+
|
|
131
146
|
# How to identify the subscription owner in the billing portal
|
|
132
147
|
config.subscription_owner_authenticator do
|
|
133
148
|
current_user || warden.authenticate!(scope: :user)
|
|
134
149
|
end
|
|
135
|
-
|
|
150
|
+
|
|
136
151
|
# Where the "Back" link goes in the portal
|
|
137
152
|
config.customer_portal_back_path do
|
|
138
153
|
main_app.root_path
|
|
@@ -140,6 +155,15 @@ PaddleRails.configure do |config|
|
|
|
140
155
|
end
|
|
141
156
|
```
|
|
142
157
|
|
|
158
|
+
### Credential Lookup Order
|
|
159
|
+
|
|
160
|
+
Each credential is resolved in this order:
|
|
161
|
+
|
|
162
|
+
1. **Explicit config** — value set in the initializer block
|
|
163
|
+
2. **Environment variable** — `PADDLE_API_KEY`, `PADDLE_PUBLIC_TOKEN`, `PADDLE_ENVIRONMENT`, `PADDLE_WEBHOOK_SECRET`
|
|
164
|
+
3. **Rails credentials** — `rails credentials:edit` under the `paddle:` key
|
|
165
|
+
4. **Default** — `"sandbox"` for environment, `nil` for everything else
|
|
166
|
+
|
|
143
167
|
### Paddle Dashboard Settings
|
|
144
168
|
|
|
145
169
|
#### Default Payment Link
|