Create a Subscription

Create a new subscription

POST /subscriptions

Facades MERCHANT

HTTP Request

An example code to create a new subscription

let subscription;
let subscriptions;
let items = [];
let billData;
let subscriptionObj;
let lastSubscription;
let retrievedSubscription;
let updatedSubscription;

items.push(new SubscriptionItem(6, 10, "Item 1"));
items.push(new SubscriptionItem(4.3, 35, "Item 2"));

billData = new BillData('USD', '[email protected]', '2021-02-21', items);
billData.cc = '[email protected]';
billData.passProcessingFee = true;
billData.emailBill = true;
billData.name = 'aaaa';
billData.currency = 'USD';
billData.email = '[email protected]';

subscriptionObj = new Subscription();
subscriptionObj.id = '123';
subscriptionObj.status = 'draft';
subscriptionObj.nextDelivery = '2021-02-19';
subscriptionObj.schedule = 'weekly';
subscriptionObj.billData = billData;

subscription = await client.CreateSubscription(subscriptionObj);
{
    "facade": "merchant/subscription",
    "data": {
        "id": "SeL33Hjyr3VmFHA5Skc4zy",
        "status": "draft",
        "billData": {
        "emailBill": true,
        "cc": [
            "[email protected]"
        ],
        "number": "subscription1234-ABCD",
        "currency": "USD",
        "name": "John Doe",
        "address1": "2630 Hegal Place",
        "address2": "Apt 42",
        "city": "Alexandria",
        "state": "VA",
        "zip": "23242",
        "country": "US",
        "email": "[email protected]",
        "phone": "555-123-456",
        "dueDate": "2021-05-31T00:00:00.000Z",
        "passProcessingFee": true,
        "items": [
            {
            "description": "Test Item 1",
            "price": 6,
            "quantity": 1
            },
            {
            "description": "Test Item 2",
            "price": 4,
            "quantity": 1
            }
        ],
        "merchant": "5461e13dfd8b0047590d644a"
        },
        "schedule": "0 0 0 * * 1",
        "nextDelivery": "2021-05-24T00:00:00.000Z",
        "createdDate": "2021-05-21T12:29:54.428Z",
        "token": "85yxWk7aEgPdJME6zTkXkAGA3K13MtXf3WHqvtBvyhw3ycfEebJ5WMBRZHXsssSBvn"
    }
}