Creating an OnDemand Plan
This document provides a comprehensive guide for creating an On-Demand Plan using the PortOne API. An On-Demand Plan allows merchants to charge customers based on their usage or activity without fixed intervals.
API Endpoint
POST https://api.portone.cloud/api/subscription/createPlan
Headers
Content-Type
Content-Typestring Ā· required
Set to application/json.
X-Portone-Client-Key
X-Portone-Client-Keystring Ā· required
The unique PortOne key for the merchant.
Authorization
Authorizationstring Ā· required
JWT for authenticating API requests. Learn how to generate the token here.
Request Example
Request Body:
{
"portone_key": "PORTONE_KEY",
"merchant_order_ref": "Plan_1729672233766",
"source": "api",
"currency": "USD",
"name": "OnDemand USD plan",
"description": "OnDemand USD plan",
"environment": "sandbox",
"plan_type": "ONDEMAND",
"notes": [
{ "key": "key1", "value": "value1" },
{ "key": "key2", "value": "value2" }
]
}Request Body Parameters
Below are the required and optional parameters for creating an On-Demand Plan:
General Parameters
portone_key
portone_keystring Ā· required
The unique PortOne key for the merchant.
signature_hash
signature_hashstring Ā· required
Signature hash generated as per On-Demand Plan Request Signature Documentation.
merchant_order_ref
merchant_order_refstring Ā· required
The unique merchant order reference generated by the merchant.
source
sourcestring Ā· required
The source of plan creation: default, api, or checkout.
description
descriptionstring
A description of the plan.
environment
environmentstring Ā· required
Plan environment, either live or sandbox.
name
namestring Ā· required
Name of the plan.
notes
array of objects
The JSON array for additional notes
> ##### key
string Ā· The key describing the note. Example:special_instructionsorgift_wrap.
value
string Ā· The value of the note. Example:Deliver between 9-11 AMorYes.
On-Demand Plan-Specific Parameters
currency
currencystring Ā· required
Currency of the plan (e.g., USD).
plan_type
plan_typestring Ā· required
Type of plan. Set to ONDEMAND.
Response
Success Response
{
"is_success": true,
"merchant_order_ref": "Subscription_1729672233761",
"order_ref": "2nsJNracNOB6mzJ4elECMmnOlu2",
"subscription_link": "https://subscription.portone.cloud/?ref=2nsJNracNOB6mzJ4elECMmnOlu2",
"status_code": "200"
}Error Response
{
"is_success": false,
"message": "The API request failed due to invalid parameters.",
"status_code": "400",
"status_reason": "Bad Request"
}Best Practices
- Environment Selection: Use
sandboxfor testing andlivefor production. - Validation: Ensure all required fields are correctly validated before sending the request.
- Testing: Test your API integration in the sandbox environment before moving to production.
Key Notes
- OnDemand Plans: Ideal for usage-based subscriptions or services with variable billing.
- Descriptive Details: Use descriptive names and notes for easier plan management and tracking.
This document serves as a comprehensive guide to creating OnDemand Plans with the PortOne API.
Updated 11 months ago