Skip to content

Commit

Permalink
Finish renaming paddle billing
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed Oct 26, 2023
2 parents 78447ba + bad8fc8 commit 1a7066c
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Pay
module Webhooks
class PaddleController < Pay::ApplicationController
class PaddleBillingController < Pay::ApplicationController
if Rails.application.config.action_controller.default_protect_from_forgery
skip_before_action :verify_authenticity_token
end
Expand All @@ -10,16 +10,16 @@ def create
queue_event(verify_params.as_json)
head :ok
end
rescue Pay::Paddle::Error
rescue Pay::PaddleBilling::Error
head :bad_request
end

private

def queue_event(event)
return unless Pay::Webhooks.delegator.listening?("paddle.#{params[:event_type]}")
return unless Pay::Webhooks.delegator.listening?("paddle_billing.#{params[:event_type]}")

record = Pay::Webhook.create!(processor: :paddle, event_type: params[:event_type], event: event)
record = Pay::Webhook.create!(processor: :paddle_billing, event_type: params[:event_type], event: event)
Pay::Webhooks::ProcessJob.perform_later(record)
end

Expand All @@ -31,7 +31,7 @@ def valid_signature?(paddle_signature)

signed_payload = "#{ts}:#{request.raw_post}"

key = Pay::Paddle.signing_secret
key = Pay::PaddleBilling.signing_secret
data = signed_payload
digest = OpenSSL::Digest.new("sha256")

Expand Down
12 changes: 6 additions & 6 deletions docs/2_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ braintree:
public_key: yyyy
merchant_id: aaaa
environment: sandbox
paddle:
paddle_billing:
seller_id: 1111
api_key: yyyy
signing_secret: pdl_ntfset...
Expand Down Expand Up @@ -60,10 +60,10 @@ Pay will also check environment variables for API keys:
* `BRAINTREE_PUBLIC_KEY`
* `BRAINTREE_PRIVATE_KEY`
* `BRAINTREE_ENVIRONMENT`
* `PADDLE_SELLER_ID`
* `PADDLE_API_KEY`
* `PADDLE_SIGNING_SECRET`
* `PADDLE_ENVIRONMENT`
* `PADDLE_BILLING_SELLER_ID`
* `PADDLE_BILLING_API_KEY`
* `PADDLE_BILLING_SIGNING_SECRET`
* `PADDLE_BILLING_ENVIRONMENT`
* `PADDLE_CLASSIC_VENDOR_ID`
* `PADDLE_CLASSIC_VENDOR_AUTH_CODE`
* `PADDLE_CLASSIC_PUBLIC_KEY`
Expand Down Expand Up @@ -118,7 +118,7 @@ Pay.setup do |config|
config.automount_routes = true
config.routes_path = "/pay" # Only when automount_routes is true
# All processors are enabled by default. If a processor is already implemented in your application, you can omit it from this list and the processor will not be set up through the Pay gem.
config.enabled_processors = [:stripe, :braintree, :paddle]
config.enabled_processors = [:stripe, :braintree, :paddle_billing, :paddle_classic]

# To disable all emails, set the following configuration option to false:
config.send_emails = true
Expand Down
2 changes: 1 addition & 1 deletion docs/3_customers.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Before you can process payments, you need to assign a payment processor for the
```ruby
@user.set_payment_processor :stripe
@user.set_payment_processor :braintree
@user.set_payment_processor :paddle
@user.set_payment_processor :paddle_billing
@user.set_payment_processor :paddle_classic
@user.set_payment_processor :fake_processor, allow_fake: true
```
Expand Down
2 changes: 1 addition & 1 deletion docs/4_payment_methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ To update the default payment method on file, you can use `update_payment_metho

This will add the payment method via the API and mark it as the default for future payments.

##### Paddle
##### Paddle Billing

For updating payment method details on Paddle, a transaction ID is required. This can be generated by using

Expand Down
4 changes: 2 additions & 2 deletions docs/7_webhooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To configure webhooks on your payment processor, use the following URLs (with yo

* **Stripe** - `https://example.org/pay/webhooks/stripe`
* **Braintree** - `https://example.org/pay/webhooks/braintree`
* **Paddle** - `https://example.org/pay/webhooks/paddle`
* **Paddle Billing** - `https://example.org/pay/webhooks/paddle_billing`
* **Paddle Classic** - `https://example.org/pay/webhooks/paddle_classic`

#### Mount path
Expand Down Expand Up @@ -51,7 +51,7 @@ Since we support multiple payment providers, each event type is prefixed with th
```ruby
"stripe.charge.succeeded"
"braintree.subscription_charged_successfully"
"paddle.subscription.created"
"paddle_billing.subscription.created"
"paddle_classic.subscription_created"
```

Expand Down
12 changes: 6 additions & 6 deletions docs/paddle/1_overview.md → docs/paddle_billing/1_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Using Pay with Paddle
# Using Pay with Paddle Billing

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
Expand All @@ -14,7 +14,7 @@ Paddle now works similar to Stripe. You create a customer, which subscriptions b

```ruby
# Set the payment processor
@user.set_payment_processor :paddle
@user.set_payment_processor :paddle_billing

# Create the customer on Paddle
@user.payment_processor.customer
Expand Down Expand Up @@ -55,7 +55,7 @@ this after creating a webhook in the Paddle dashboard. You'll find this page
Pay will automatically look for the following environment variables, or the equivalent
Rails credentials:

- `PADDLE_SELLER_ID`
- `PADDLE_ENVIRONMENT`
- `PADDLE_API_KEY`
- `PADDLE_SIGNING_SECRET`
- `PADDLE_BILLING_SELLER_ID`
- `PADDLE_BILLING_ENVIRONMENT`
- `PADDLE_BILLING_API_KEY`
- `PADDLE_BILLING_SIGNING_SECRET`
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Paddle Webhooks
# Paddle Billing Webhooks

## Endpoint

The webhook endpoint for Paddle is `/pay/webhooks/paddle` by default.
The webhook endpoint for Paddle Billing is `/pay/webhooks/paddle_billing` by default.

## Events

Expand Down
1 change: 1 addition & 0 deletions lib/pay/paddle_billing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Webhooks

def self.enabled?
return false unless Pay.enabled_processors.include?(:paddle_billing) && defined?(::Paddle)

Pay::Engine.version_matches?(required: "~> 2.1", current: ::Paddle::VERSION) || (raise "[Pay] paddle gem must be version ~> 2.1")
end

Expand Down
2 changes: 1 addition & 1 deletion lib/pay/paddle_billing/charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def self.sync(charge_id, object: nil, try: 0, retries: 1)
# Ignore charges without a Customer
return if object.customer_id.blank?

pay_customer = Pay::Customer.find_by(processor: :paddle, processor_id: object.customer_id)
pay_customer = Pay::Customer.find_by(processor: :paddle_billing, processor_id: object.customer_id)
return unless pay_customer

# Ignore transactions that are payment method changes
Expand Down
2 changes: 1 addition & 1 deletion lib/pay/paddle_billing/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def self.sync(subscription_id, object: nil)
# Passthrough is not return from this API, so we can't use that
object ||= ::Paddle::Subscription.retrieve(id: subscription_id)

pay_customer = Pay::Customer.find_by(processor: :paddle, processor_id: object.customer_id)
pay_customer = Pay::Customer.find_by(processor: :paddle_billing, processor_id: object.customer_id)
return unless pay_customer

attributes = {
Expand Down

0 comments on commit 1a7066c

Please sign in to comment.