For AI agents and LLMs: a structured documentation index is available at /llms.txt. Every page has a Markdown sibling — append .md to any URL.

Skip to content
Docs

Add a hosted checkout to your mobile app

Get a step-by-step overview of how to add a Paddle-hosted external purchase flow for your iOS app, letting you go direct to customers while remaining compliant.

AI summary

Add a Paddle-hosted external purchase flow to your iOS app by creating a hosted checkout in the dashboard and constructing a URL with a price_id query parameter that opens in Safari.

  • • Create a hosted checkout under Paddle > Checkout > Hosted checkout, set a redirect URL using your app's custom URL scheme (e.g., myapp://example-redirect), and copy the checkout launch URL.
  • • Construct the checkout URL by appending ?price_id={priceId} to the hosted checkout URL — pass default prices in the dashboard to open without a price_id parameter.
  • • Pass URL parameters such as user_email, country_code, postal_code, and app_user_id to prefill customer information and improve conversion; pass app_user_id for RevenueCat integration.

Hosted checkout requires additional approval

Hosted checkout requires additional approval to use on live accounts. Read the docs to see how it works, then email sellers@paddle.com to request access. We'll reach out if you meet the program requirements. You can test it on sandbox in the meantime.

With recent developments in legislation around the App Store, you can link users in the United States flagUnited States to an external checkout for purchases in iOS apps.

You can use hosted checkouts to let users securely make purchases outside your app — no hosting required. Customers tap a button in your app to open a checkout that's fully hosted by Paddle, then they're redirected to your app when they complete their purchase.

What are we building?

In this tutorial, we'll use hosted checkouts in Paddle to build an external purchase flow for in-app purchases in iOS apps.

We'll walk through handling fulfillment using the RevenueCat x Paddle integration or webhooks.

What's not covered

This tutorial doesn't cover:

  • Handling authentication
    We assume you already have a way to identify your users, like Firebase or Sign in with Apple.
  • Native in-app purchases
    We'll launch Paddle Checkout in Safari then redirect users back to your app. Like the App Store, Paddle Checkout supports Apple Pay with no additional setup, plus other popular payment options.
  • Subscription lifecycle management
    You can use Paddle to handle all parts of the subscription lifecycle, including updating payment methods and canceling subscriptions using the prebuilt customer portal. We cover that elsewhere in our docs.

Before you begin

Sign up for Paddle

You'll need a Paddle account to get started. You can sign up for two kinds of account:

  • Sandbox — for testing and evaluation
  • Live — for selling to customers

For this tutorial, we recommend signing up for a sandbox account. You can transition to a live account later when you've built your integration and you're ready to start selling. If you sign up for a live account, you'll need to:

Prep your iOS development environment

As part of our tutorial, we're going to update our app to include a link to a hosted checkout for purchases. You'll need:

  • Some knowledge of iOS development, access to your iOS project, and Xcode on macOS.
  • A correctly configured URL scheme so you can redirect users back to your app.

You don't need to make changes to your iOS app to create a hosted checkout in Paddle, so you can come back to this later if you're working with a developer.

Overview

Add a hosted checkout to your app to link out for in-app purchases in five steps:

  1. Map your product catalog
    Create products and prices in Paddle that match your in-app purchase options.
  2. Create a hosted checkout
    Create a hosted checkout in the Paddle dashboard, including where to redirect customers to after purchase.
  3. Add a checkout button to your app
    Create a button that opens the hosted checkout URL when tapped.
  4. Handle fulfillment and provisioning
    Use RevenueCat or process webhooks to fulfill purchases after a customer completes a checkout.
  5. Take a test payment
    Make a test purchase to make sure your purchase flow works correctly.

Map your product catalog

Before we add a hosted checkout to our app, we need to set up our product catalog in Paddle to match the in-app purchases we offer.

Model your pricing

A complete product in Paddle is made up of two parts:

  • A product entity that describes the item, like its name, description, and an image.
  • At least one related price entity that describes how much and how often a product is billed.

You can create as many prices for a product as you want to describe all the ways they're billed.

In this example, we'll create a single product and single price for a one-time item called Lifetime Access.

Create products and prices

You can create products and prices using the Paddle dashboard or the API.

  1. Go to Paddle > Catalog > Products.
  2. Click New product
  3. Enter details for your new product, then click Save when you're done.
  4. Under the Prices section on the page for your product, click New price
  5. Enter details for your new price. Set the type to One-time to create a one-time price.
  6. Click Save when you're done.
  7. Click the button next to a price in the list, then choose Copy price ID from the menu. Keep this for later.

Illustration showing the new product drawer in Paddle. It shows fields for product name, tax category, and description

Prices list in the Paddle dashboard, with the action menu open and copy ID selected.

Create a hosted checkout

Next, create a hosted checkout. A hosted checkout is a link that users can use to make a purchase. It's unique to your account.

You can create multiple hosted checkouts if you have different apps or want to create links that redirect to different places in your app.

When creating a hosted checkout, you can set default prices. If you don't pass prices or a transaction to the checkout directly, the default prices are used instead.

  1. Go to Paddle > Checkout > Hosted checkout.
  2. Click New hosted checkout
  3. Enter a name and a description. This is typically your app name and any details for your reference. They're not shown to customers.
  4. Enter a redirect URL. This should be a custom URL scheme or universal link that bounces users back to your app when their purchase is completed, for example myapp://example-redirect.
  5. Optionally, paste the price ID you copied previously to the list of Default prices if you want this to be opened on every launch of the hosted checkout. You can add multiple price IDs if you have them to hand.
  6. Click Save when you're done.
  7. Click the button next to the hosted checkout you just created, then choose Copy URL from the menu. Keep this for the next step.

Screenshot of the Paddle dashboard showing the 'New hosted checkout' form. The form includes required fields for Name, an optional Description text area with an information icon, and an optional Redirect URL field with an information icon. There's a 'Save' button in the blue color in the top right corner of the form."

Screenshot of the Paddle dashboard 'Hosted checkouts' list view. The interface displays a table with columns for Name, Description, and Redirect URL. Multiple entries are shown with placeholder content. A context menu is open for one of the items showing three options: Edit (with pencil icon), Copy URL (with copy icon), and Archive (with trash icon in red).

Add a checkout button to your app

Now, update your iOS app to add a button that:

  1. Checks to see if in-app purchases are allowed on the device.
  2. Checks to see if a user already purchased the item.
  3. Constructs a URL using your hosted checkout launch URL, and a price_id query parameter with the price ID you copied previously as the value.

Here's an example using SwiftUI:

PurchaseView.swift
import SwiftUI
import StoreKit // required for checking device payment capabilities using SKPaymentQueue
struct PurchaseView: View {
let checkoutBaseURL = "https://pay.paddle.io/checkout/hsc_01jt8s46kx4nv91002z7vy4ecj_1as3scas9cascascasasx23dsa3asd2a" // replace with your checkout launch URL
let priceId = "pri_01h1vjg3sqjj1y9tvazkdqe5vt" // replace with a price ID or dynamically set it
var body: some View {
VStack {
// Check if the device can make payments
if SKPaymentQueue.canMakePayments() {
// Create a purchase button with styling
Button("Buy now") {
openCheckout()
}
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
} else {
// Fallback text when purchases aren't available
Text("Purchases not available on this device.")
.foregroundColor(.secondary)
}
}
.padding()
}
// Function to construct and open the checkout URL
func openCheckout() {
// Create URL with price_id parameter
let checkoutURL = "\(checkoutBaseURL)?price_id=\(priceId)"
if let url = URL(string: checkoutURL) {
// Open URL in the default browser
UIApplication.shared.open(url)
}
}
}

Prefill information Recommended

To make for a more seamless user experience, you can use URL parameters to pass additional information to the hosted checkout.

In this updated example, we pass customer details and a unique identifier for the customer in RevenueCat.

PurchaseView.swift
import SwiftUI
import StoreKit // required for checking device payment capabilities using SKPaymentQueue
struct PurchaseView: View {
let checkoutBaseURL = "https://pay.paddle.io/checkout/hsc_01jt8s46kx4nv91002z7vy4ecj_1as3scas9cascascasasx23dsa3asd2a" // replace with your checkout launch URL
let priceId = "pri_01h1vjg3sqjj1y9tvazkdqe5vt" // replace with a price ID or dynamically set it
// Additional information
// In a real app, this would come from your user authentication platform
let appUserId = "85886aac-eef6-41df-8133-743cbb1daa4b"
let userEmail = "sam@example.com"
let countryCode = "US"
let postalCode = "10021"
var body: some View {
VStack {
// Check if the device can make payments
if SKPaymentQueue.canMakePayments() {
// Create a purchase button with styling
Button("Buy now") {
openCheckout()
}
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
} else {
// Fallback text when purchases aren't available
Text("Purchases not available")
.foregroundColor(.secondary)
}
}
.padding()
}
// Function to construct and open the checkout URL with customer data
func openCheckout() {
// Create URL components for building a URL with query parameters
var urlComponents = URLComponents(string: checkoutBaseURL)!
// Add the price ID and customer information as query parameters
urlComponents.queryItems = [
URLQueryItem(name: "price_id", value: priceId),
URLQueryItem(name: "app_user_id", value: appUserId),
URLQueryItem(name: "user_email", value: userEmail),
URLQueryItem(name: "country_code", value: countryCode),
URLQueryItem(name: "postal_code", value: postalCode)
]
// Open the checkout URL if it's valid
if let url = urlComponents.url {
UIApplication.shared.open(url)
}
}
}

Handle fulfillment and provisioning

When a customer completes a purchase, they'll be redirected back to your app. At this point, you need to handle fulfillment and unlock the features they bought.

If you use the RevenueCat x Paddle integration to handle entitlements, you're all set.

Here's how it works:

  1. Paddle automatically sends data to RevenueCat about the completed checkout.
  2. RevenueCat grants the user an entitlement based on your product configuration.
  3. Use the RevenueCat SDK to check entitlement status in your iOS app.

You can use webhooks to build your own fulfillment workflow. In this example, we'll grant users access when they've purchased our Lifetime Access product.

Build a webhook handler

When a customer creates or completes a transaction, Paddle can send a webhook to an endpoint you set up. You can store details of the transaction in your database and associate it with the user's account.

Add a new endpoint to the existing server-side code as set up in Set up the endpoint.

server.js
app.post("/paddle/webhooks", express.raw({ type: 'application/json' }), async (req, res) => {
try {
// You can verify the webhook signature here
// We don't cover this in the tutorial but it's best practice to do so
// https://developer.paddle.com/webhooks/signature-verification
const payload = JSON.parse(req.body.toString());
const { data, event_type } = payload;
const occurredAt = payload.occurred_at;
// Listen for vital events from Paddle
switch (event_type) {
// 1. Record transactions in the database
// Handle a new transaction
// You can create a Transaction database to store records and associate them to a user
case 'transaction.created':
// Find the user associated with this transaction
const userForTransaction = await User.findOne({ where: { paddleCustomerId: data.customer_id } });
if (userForTransaction) {
await Transaction.create({
transactionId: data.id,
userId: userForTransaction.id,
subscriptionId: data.subscription_id,
status: data.status,
amount: data.amount,
currencyCode: data.currency_code,
occurredAt: occurredAt
});
}
break;
// Handle a completed transaction
// If you have a Transaction database, you can update the transaction record
case 'transaction.completed':
// Find the transaction by its ID
const completedTransaction = await Transaction.findOne({
where: { transactionId: data.id }
});
if (completedTransaction) {
await completedTransaction.update({
status: data.status,
subscriptionId: data.subscription_id,
invoiceId: data.invoice_id,
invoiceNumber: data.invoice_number,
billedAt: data.billed_at,
updatedAt: data.updated_at
});
}
break;
}
res.json({ received: true });
} catch (error) {
console.error('Error processing webhook:', error);
return res.status(500).json({ error: error.message });
}
});

Unlock user access

When you receive the transaction.completed webhook, you can use the details to handle order fulfillment and provisioning.

The example below updates a user's access permissions in your database. After this, your iOS app can check for the lifetimeAccess permission to unlock premium features.

server.js
app.post("/paddle/webhooks", express.raw({ type: 'application/json' }), async (req, res) => {
try {
// You can verify the webhook signature here
// We don't cover this in the tutorial but it's best practice to do so
// https://developer.paddle.com/webhooks/signature-verification
const payload = JSON.parse(req.body.toString());
const { data, event_type } = payload;
const occurredAt = payload.occurred_at;
// Listen for vital events from Paddle
switch (event_type) {
// 1. Record transactions in the database
// Handle a new transaction
// You can create a Transaction database to store records and associate them to a user
case 'transaction.created':
// Find the user associated with this transaction
const userForTransaction = await User.findOne({ where: { paddleCustomerId: data.customer_id } });
if (userForTransaction) {
await Transaction.create({
transactionId: data.id,
userId: userForTransaction.id,
subscriptionId: data.subscription_id,
status: data.status,
amount: data.amount,
currencyCode: data.currency_code,
occurredAt: occurredAt
});
}
break;
// Handle a completed transaction
// If you have a Transaction database, you can update the transaction record
case 'transaction.completed':
// Find the transaction by its ID
const completedTransaction = await Transaction.findOne({
where: { transactionId: data.id }
});
if (completedTransaction) {
await completedTransaction.update({
status: data.status,
subscriptionId: data.subscription_id,
invoiceId: data.invoice_id,
invoiceNumber: data.invoice_number,
billedAt: data.billed_at,
updatedAt: data.updated_at
});
// 2. Provision access to your app
// Fetch the user associated with this transaction
const user = await User.findOne({ where: { id: completedTransaction.userId } });
if (user) {
// Fetch the items from the transaction
const purchasedItems = data.items || [];
// Add what access the user has based on the items they purchased
// For this example, we're using access permissions and storing them in the user model on an accessPermissions field
// We also map the Paddle product IDs to the access permissions
// In a real app, you could use a database table for this mapping
// Get existing permissions to see if any first
const accessPermissions = user.accessPermissions ? JSON.parse(user.accessPermissions) : {};
// Map product IDs to access permissions
// We add an additional product as an example of how you can handle multiple
const productToPermission = {
'pro_01h1vjes1y163xfj1rh1tkfb65': 'lifetimeAccess',
'pro_01gsz97mq9pa4fkyy0wqenepkz': 'temporaryAccess'
}
purchasedItems.forEach(({ price }) => {
const permissionKey = productToPermission[price.product_id];
if (permissionKey) accessPermissions[permissionKey] = true;
});
// Update the user with their new access permissions
await user.update({
accessPermissions: JSON.stringify(accessPermissions),
});
}
}
break;
}
res.json({ received: true });
} catch (error) {
console.error('Error processing webhook:', error);
return res.status(500).json({ error: error.message });
}
});

Create a notification destination

To start receiving webhooks, create a notification destination. This is where you can tell Paddle which events you want to receive and where to deliver them to.

  1. Go to Paddle > Developer tools > Notifications.
  2. Click New destination .
  3. Set Notification type to URL and enter the URL for your webhook handler.
  4. Choose the transaction.completed event. You can always edit events later.
  5. Click Save destination .

Illustration of the new destination drawer in Paddle. It shows fields for description, type, URL, and version. Under those fields, there's a section called events with a checkbox that says 'select all events'

Test the complete flow

We're now ready to test the complete purchase flow end-to-end! If you're using a sandbox account, you can take a test payment using our test card details:

Email address

An email address you own

Country

Any valid country supported by Paddle

ZIP code (if required)

Any valid ZIP or postal code

Card number

4242 4242 4242 4242

Name on card

Any name

Expiration date

Any valid date in the future.

Security code

100

Next steps

That's it. Now you've built a purchase workflow that links out to Paddle Checkout, you might like to hook into other features of the Paddle platform.

Learn more about Paddle

When you use Paddle, we take care of payments, tax, subscriptions, and metrics with one unified platform. Customers can self-serve with the portal, and Paddle handles any order inquiries for you.

Build a web checkout

Our tutorial uses a hosted checkout to build a payment workflow. You can also Paddle.js to build pricing pages and signup flows on the web, then redirect people to your app.

Build advanced subscription functionality

Paddle Billing is designed for subscriptions as well as one-time items. You can use Paddle to build workflows to pause and resume subscriptions, flexibly change billing dates, and offer trials.

Was this page helpful?