forked from pay-rails/pay
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'paddle-billing-updates' of github.com:deanpcmad/pay int…
…o paddle-billing-updates * 'paddle-billing-updates' of github.com:deanpcmad/pay: Paddle Billing Docs (pay-rails#873) Update 1_installation.md with Stripe version 10 (pay-rails#880) Add Rails 7.1 to tests and remove Ruby 2.7 as it's EOL (pay-rails#878) Fix issue with Paddle Billing Charges when there's no payment details (pay-rails#872) Merge session_id into return_url for Stripe Checkout Stripe v10 Update github actions to use main branch (pay-rails#871)
- Loading branch information
Showing
29 changed files
with
629 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,61 @@ | ||
# Using Pay with Paddle | ||
|
||
Paddle works differently than most of the other payment processors so it comes with some limitations and differences. | ||
Paddle Billing is Paddle's new subscription billing platform. It differs quite a bit | ||
from Paddle Classic. This guide will help you get started with implementing it in your | ||
Rails application. | ||
|
||
* You cannot create a Customer from the API | ||
* Checkout only happens via iFrame or hosted page | ||
* Cancelling a subscription cannot be resumed | ||
* Payment methods can only be updated while a subscription is active | ||
* Paddle customers are not reused when a user re-subscribes | ||
|
||
## Paddle Sandbox | ||
## Creating Customers | ||
|
||
The [Paddle Sandbox](https://developer.paddle.com/getting-started/sandbox) can be used for testing your Paddle integration. | ||
Paddle now works similar to Stripe. You create a customer, which subscriptions belong to. | ||
|
||
```html | ||
<script src="https://cdn.paddle.com/paddle/paddle.js"></script> | ||
<script type="text/javascript"> | ||
Paddle.Environment.set('sandbox'); | ||
Paddle.Setup({ vendor: <%= Pay::Paddle.vendor_id %> }); | ||
</script> | ||
```ruby | ||
# Set the payment processor | ||
@user.set_payment_processor :paddle | ||
|
||
# Create the customer on Paddle | ||
@user.payment_processor.customer | ||
``` | ||
## Paddle Public Key | ||
|
||
Paddle uses public/private keys for webhook verification. You can find | ||
your public key [here for Production](https://vendors.paddle.com/public-key) | ||
and [here for Sandbox](https://sandbox-vendors.paddle.com/public-key). | ||
## Prices & Plans | ||
|
||
There are 3 ways that you can set the public key in Pay. | ||
Paddle introduced Products & Prices to support more payment options. Previously, | ||
they Products and Plans separated. | ||
|
||
In either example, you can set the environment variable or in Rails credentials. | ||
## Subscriptions | ||
|
||
### File | ||
Paddle subscriptions are not created through the API, but through Webhooks. When a | ||
subscription is created, Paddle will send a webhook to your application. Pay will | ||
automatically create the subscription for you. | ||
|
||
You can download the public key from the link above and save it to a location which your Rails application | ||
can access. Then set the `PADDLE_PUBLIC_KEY_FILE` to the location of the file. | ||
## Configuration | ||
|
||
### Key | ||
### Paddle API Key | ||
|
||
Set the `PADDLE_PUBLIC_KEY` environment variable with your public key. Replace any spaces with `\n` otherwise | ||
you may get a `OpenSSL::PKey::RSAError` error. | ||
You can generate an API key [here for Production](https://vendors.paddle.com/authentication) | ||
or [here for Sandbox](https://sandbox-vendors.paddle.com/authentication) | ||
|
||
### Base64 Encoded Key | ||
### Paddle Environment | ||
|
||
Or you can set a Base64 encoded version of the key. To do this, download a copy of your public key | ||
then open a `rails console` and enter the following: | ||
Paddle has two environments: Sandbox and Production. To use the Sandbox environment, | ||
set the Environment value to `sandbox`. By default, this is set to `production`. | ||
|
||
```ruby | ||
paddle_public_key = OpenSSL::PKey::RSA.new(File.read("paddle.pem")) | ||
Base64.encode64(paddle_public_key.to_der) | ||
``` | ||
### Paddle Signing Secret | ||
|
||
Paddle uses a signing secret to verify that webhooks are coming from Paddle. You can find | ||
this after creating a webhook in the Paddle dashboard. You'll find this page | ||
[here for Production](https://vendors.paddle.com/notifications) or | ||
[here for Sandbox](https://sandbox-vendors.paddle.com/notifications). | ||
|
||
### Environment Variables | ||
|
||
Pay will automatically look for the following environment variables, or the equivalent | ||
Rails credentials: | ||
|
||
Copy what's displayed and set the `PADDLE_PUBLIC_KEY_BASE64` environment variable. | ||
- `PADDLE_SELLER_ID` | ||
- `PADDLE_ENVIRONMENT` | ||
- `PADDLE_API_KEY` | ||
- `PADDLE_SIGNING_SECRET` |
Oops, something went wrong.