Superface

Create Subscription Plan

payments/create-plan@1.0.0
2 providers

Create Subscription Plan

Creates a subscription plan in a payment system.

Input
Product ID
Name
Interval
Price
Currency code
Result
Plan ID
State

1.Choose a provider

2.Use CreatePlan with mock in your code

Below instructions are for our Node.js SDK. Use OneService for other languages.
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();

Structure details

Input (object)

productId
The ID of the product to create a subscription plan for. (To be created with `payments/create-product`)
name
Name of the subscription plan
interval
Frequency of the interval at which the customer is charged. Possible values: - `day` - `week` - `month` - `year`
price
Amount charged each `interval` cycle.
currency
Three-letter currency code in which `price` is specified, in ISO 4217 format.

Example

{
  "productId": "PROD-1192810198",
  "name": "Monthly subscription to Superface milk delivery",
  "interval": "month",
  "price": 25,
  "currency": "USD"
}

Result (object)

planId
ID of the plan.
state
State of the plan. Possible values: - `created` - The plan was just created. It may not be possible to accept new subscriptions yet. - `active` - The plan is active and accepting new subscriptions. - `inactive` - The plan has been deactivated, and cannot accept new subscriptions.

Example

{
  "planId": "PLAN-89101829211",
  "state": "active"
}

Implementation details

Provider
mock
Use case
CreatePlan
Author
@superface
Source
Verified