Set Up Subscriptions
Create products, plans, and manage recurring billing for your customers with YardPay Pro. Supports monthly, annual, one-time, and usage-based billing.
- A sandbox API key — see the Authentication guide
- Familiar with processing payments
Subscriptions in YardPay Pro are built around three resources:
Products
What you sell (e.g., "Pro Suite", "Starter Kit"). Products group related plans together.
Plans
Pricing & billing configuration (e.g., "$29.99/month", "$299.99/year"). Each product can have multiple plans.
Inventory
Physical or digital items tracked by serial number (e.g., device rentals, license keys).
Create a Product
Start by creating a product. The product type determines how it's categorized: Service, Digital, or Physical.
curl -X POST /v1/SubscriptionProduct \
-H "Content-Type: application/json" \
-H "x-api-key: sk_test_YOUR_API_KEY" \
-d '{
"name": "Business Suite",
"description": "Complete business management toolkit",
"subscriptionProductType": "Service"
}'// Response
{
"id": 1,
"merchantId": 10,
"name": "Business Suite",
"description": "Complete business management toolkit",
"subscriptionProductType": "Service",
"createdDateTime": "2026-03-28T10:00:00Z"
}Add Subscription Plans
Create one or more pricing plans for your product. Set the billing interval using timeUnit and timeInterval.
Monthly Plan
curl -X POST /v1/SubscriptionPlan \
-H "Content-Type: application/json" \
-H "x-api-key: sk_test_YOUR_API_KEY" \
-d '{
"productId": 1,
"name": "Monthly",
"description": "Billed monthly",
"amount": "29.99",
"currency": "USD",
"timeUnit": "Month",
"timeInterval": 1,
"subscriptionBillingType": "Recurring",
"status": "Active"
}'Annual Plan (discounted)
curl -X POST /v1/SubscriptionPlan \
-H "Content-Type: application/json" \
-H "x-api-key: sk_test_YOUR_API_KEY" \
-d '{
"productId": 1,
"name": "Annual",
"description": "Billed yearly — save 17%",
"amount": "299.99",
"currency": "USD",
"timeUnit": "Year",
"timeInterval": 1,
"subscriptionBillingType": "Recurring",
"status": "Active"
}'| Billing Type | Description | Example |
|---|---|---|
| Recurring | Automatically charges at each interval | $29.99/month |
| OneTime | Single charge, no renewal | $99 lifetime access |
| Usage | Charges based on metered usage | $0.10 per API call |
| Time Unit | Time Interval | Result |
|---|---|---|
| Day | 7 | Weekly billing |
| Month | 1 | Monthly billing |
| Month | 3 | Quarterly billing |
| Year | 1 | Annual billing |
Manage Inventory (Optional)
If your product involves physical items or tracked digital assets (e.g., device rentals, license keys), use inventory items to track them.
// Add inventory items
curl -X POST /v1/SubscriptionInventoryItem \
-H "Content-Type: application/json" \
-H "x-api-key: sk_test_YOUR_API_KEY" \
-d '{
"productId": 1,
"serialNumber": "SN-001-ABC",
"status": "Available"
}'| Status | Description |
|---|---|
| Available | Ready to be assigned |
| Reserved | Held for a pending order |
| Rented | Currently assigned to a subscriber |
| Discontinued | No longer available |
List and Filter Resources
All subscription endpoints support OData filtering, sorting, and pagination.
List active plans for a product
GET /v1/SubscriptionPlan?$filter=productId eq 1 and status eq 'Active'&$count=true
List available inventory
GET /v1/SubscriptionInventoryItem?$filter=status eq 'Available'&$top=20
List all products with media
GET /v1/SubscriptionProduct?$expand=Media&$orderby=id desc
import axios from 'axios';
const client = axios.create({
baseURL: window.location.origin,
headers: {
'Content-Type': 'application/json',
'x-api-key': 'sk_test_YOUR_API_KEY',
},
});
// 1. Create the product
const { data: product } = await client.post('/v1/SubscriptionProduct', {
name: 'Business Suite',
description: 'Complete business management toolkit',
subscriptionProductType: 'Service',
});
console.log('Product created:', product.id);
// 2. Create a monthly plan
const { data: monthlyPlan } = await client.post('/v1/SubscriptionPlan', {
productId: product.id,
name: 'Monthly',
amount: '29.99',
currency: 'USD',
timeUnit: 'Month',
timeInterval: 1,
subscriptionBillingType: 'Recurring',
status: 'Active',
});
console.log('Monthly plan:', monthlyPlan.id);
// 3. Create an annual plan
const { data: annualPlan } = await client.post('/v1/SubscriptionPlan', {
productId: product.id,
name: 'Annual',
amount: '299.99',
currency: 'USD',
timeUnit: 'Year',
timeInterval: 1,
subscriptionBillingType: 'Recurring',
status: 'Active',
});
console.log('Annual plan:', annualPlan.id);
// 4. List plans for verification
const { data: plans } = await client.get('/v1/SubscriptionPlan', {
params: {
$filter: `productId eq ${product.id}`,
$count: true,
},
});
console.log(`${plans['@odata.count']} plans created for ${product.name}`);