README.md in paddle-2.3.0 vs README.md in paddle-2.4.0
- old
+ new
@@ -5,11 +5,11 @@
## Installation
Add this line to your application's Gemfile:
```ruby
-gem "paddle", "~> 2.2"
+gem "paddle", "~> 2.3"
```
## Billing API
For accessing the new Billing API from Paddle. For more info, view the [Paddle Billing](https://www.paddle.com/billing) page.
@@ -99,14 +99,16 @@
# https://developer.paddle.com/api-reference/products/create-product
Paddle::Product.create(name: "My SAAS Plan", tax_category: "saas")
Paddle::Product.create(name: "My Standard Product", tax_category: "standard")
# Retrieve a product
-Paddle::Product.retrieve(id: "pro_abc123")
+product = Paddle::Product.retrieve(id: "pro_abc123")
# Update a product
# https://developer.paddle.com/api-reference/products/update-product
+product.update(description: "This is a plan")
+# or
Paddle::Product.update(id: "pro_abc123", description: "This is a plan")
```
### Prices
@@ -122,14 +124,16 @@
# Note that unit_price amount should be a string
# https://developer.paddle.com/api-reference/prices/create-price
Paddle::Price.create(product_id: "pro_abc123", description: "A one off price", amount: "1000", currency: "GBP")
# Retrieve a price
-Paddle::Price.retrieve(id: "pri_123abc")
+price = Paddle::Price.retrieve(id: "pri_123abc")
# Update a price
# https://developer.paddle.com/api-reference/prices/update-price
+price.update(description: "An updated description")
+# or
Paddle::Price.update(id: "pri_123abc", description: "An updated description")
```
### Pricing Preview
@@ -155,14 +159,16 @@
# https://developer.paddle.com/api-reference/discounts/create-discount
Paddle::Discount.create(description: "$5 off", type: "flat", amount: "500", currency_code: "USD")
Paddle::Discount.create(description: "10% Off", type: "percentage", amount: "10", code: "10OFF")
# Retrieve a discount
-Paddle::Discount.retrieve(id: "dsc_abc123")
+discount = Paddle::Discount.retrieve(id: "dsc_abc123")
# Update a discount
# https://developer.paddle.com/api-reference/discounts/update-discount
+discount.update(description: "An updated description")
+# or
Paddle::Discount.update(id: "dsc_abc123", description: "An updated description")
```
### Customers
@@ -173,18 +179,20 @@
Paddle::Customer.list(status: "active")
Paddle::Customer.list(email: "me@mydomain.com")
# Create a customer
# https://developer.paddle.com/api-reference/customers/create-customer
-# Returns a Paddle::ConflictError if the email is already used on Paddle
+# Returns a Paddle::Errors::ConflictError if the email is already used on Paddle
Paddle::Customer.create(email: "myemail@mydomain.com", name: "Customer Name")
# Retrieve a customer
-Paddle::Customer.retrieve(id: "ctm_abc123")
+customer = Paddle::Customer.retrieve(id: "ctm_abc123")
# Update a customer
# https://developer.paddle.com/api-reference/customers/update-customer
+customer.update(status: "archived")
+# or
Paddle::Customer.update(id: "ctm_abc123", status: "archived")
# Retrieve credit balance for a customer
# https://developer.paddle.com/api-reference/customers/list-credit-balances
Paddle::Customer.credit(id: "ctm_abc123")
@@ -200,14 +208,16 @@
# Create an address
# https://developer.paddle.com/api-reference/addresses/create-address
Paddle::Address.create(customer: "ctm_abc123", country_code: "GB", postal_code: "SW1A 2AA")
# Retrieve an address
-Paddle::Address.retrieve(customer: "ctm_abc123", id: "add_abc123")
+address = Paddle::Address.retrieve(customer: "ctm_abc123", id: "add_abc123")
# Update an address
# https://developer.paddle.com/api-reference/addresses/update-address
+address.update(status: "archived")
+# or
Paddle::Address.update(customer: "ctm_abc123", id: "add_abc123", status: "archived")
```
### Businesses
@@ -219,14 +229,16 @@
# Create a business
# https://developer.paddle.com/api-reference/businesses/create-business
Paddle::Business.create(customer: "ctm_abc123", name: "My Ltd Company")
# Retrieve a business
-Paddle::Business.retrieve(customer: "ctm_abc123", id: "biz_abc123")
+business = Paddle::Business.retrieve(customer: "ctm_abc123", id: "biz_abc123")
# Update a business
# https://developer.paddle.com/api-reference/businesses/update-business
+business.update(status: "archived")
+# or
Paddle::Business.update(customer: "ctm_abc123", id: "biz_abc123", status: "archived")
```
### Transactions
@@ -244,14 +256,16 @@
# Retrieve a transaction
Paddle::Transaction.retrieve(id: "txn_abc123")
# Retrieve a transaction with extra information
# extra can be either "address", "adjustment", "adjustments_totals", "business", "customer", "discount"
-Paddle::Transaction.retrieve(id: "txn_abc123", extra: "customer")
+transaction = Paddle::Transaction.retrieve(id: "txn_abc123", extra: "customer")
# Update a transaction
# https://developer.paddle.com/api-reference/transaction/update-transaction
+transaction.update(items: [ { price_id: "pri_abc123", quantity: 2 } ])
+# or
Paddle::Transaction.update(id: "txn_abc123", items: [ { price_id: "pri_abc123", quantity: 2 } ])
# Preview a transaction
# https://developer.paddle.com/api-reference/transaction/preview-transaction
Paddle::Transaction.preview(items: [ { price_id: "pri_123abc", quantity: 5 } ])
@@ -278,18 +292,20 @@
# Retrieve a subscription
Paddle::Subscription.retrieve(id: "sub_abc123")
# Retrieve a subscription with extra information
# extra can be either "next_transaction" or "recurring_transaction_details"
-Paddle::Subscription.retrieve(id: "sub_abc123", extra: "next_transaction")
+subscription = Paddle::Subscription.retrieve(id: "sub_abc123", extra: "next_transaction")
# Preview an update to a subscription
# https://developer.paddle.com/api-reference/subscriptions/preview-subscription
Paddle::Subscription.preview(id: "sub_abc123", items: [ { price_id: "pri_123abc", quantity: 2 } ])
# Update a subscription
# https://developer.paddle.com/api-reference/subscriptions/update-subscription
+subscription.update(billing_details: {purchase_order_number: "PO-1234"})
+# or
Paddle::Subscription.update(id: "sub_abc123", billing_details: {purchase_order_number: "PO-1234"})
# Get a transaction to update payment method
# https://developer.paddle.com/api-reference/subscriptions/update-payment-method
Paddle::Subscription.get_transaction(id: "sub_abc123")
@@ -365,11 +381,11 @@
```ruby
# List all notification settings
Paddle::NotificationSetting.list
# Retrieve a notification setting
-Paddle::NotificationSetting.retrieve(id: "ntfset_abc123")
+setting = Paddle::NotificationSetting.retrieve(id: "ntfset_abc123")
# Create a notification setting
# https://developer.paddle.com/api-reference/notification-settings/create-notification-setting
Paddle::NotificationSetting.create(
description: "Webhook for App",
@@ -381,9 +397,11 @@
]
)
# Update a notification setting
# https://developer.paddle.com/api-reference/notification-settings/update-notification-setting
+setting.update(subscribed_events: %w[subscription.activated transaction.completed transaction.billed])
+# or
Paddle::NotificationSetting.update(id: "ntfset_abc123",
subscribed_events: [
"subscription.activated",
"transaction.completed",
"transaction.billed"