Creates a subscription plan in a payment system.
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');
// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });
async function run() {
// Load the profile
const profile = await sdk.getProfile('payments/create-plan@1.0.0');
// Use the profile
const result = await profile
.getUseCase('CreatePlan')
.perform({
productId: 'PROD-1192810198',
name: 'Monthly subscription to Superface milk delivery',
interval: 'month',
price: 25,
currency: 'USD'
}, {
provider: 'mock'
});
// Handle the result
try {
const data = result.unwrap();
console.log(data);
} catch (error) {
console.error(error);
}
}
run();
{
"productId": "PROD-1192810198",
"name": "Monthly subscription to Superface milk delivery",
"interval": "month",
"price": 25,
"currency": "USD"
}
{
"planId": "PLAN-89101829211",
"state": "active"
}