Subscriptions

Overview

The Subscriptions API abstracts the Orders API from Woocommerce.

Creating a new subscription

It is possible to create a new subscription for a logged in customer. The following squence diagram shows the required calls to successfully create a subscription.

Create a new subscription

POST https://console.flecs.tech/api/v2/my/subscriptions

Create a new subscription for the given user.

Headers

NameTypeDescription

Authorization*

String

Bearer token

Request Body

NameTypeDescription

customer_id*

Number

payment_method*

String

"b2bking-invoice-gateway"

billing*

Object

{ first_name: String, last_name: String, company: String, address: String, city: String, postcode: String, state: String, country: String, email: String,

vat: String }

line_items*

Array

[ { product_id: Number, quantity: Number } ]

statusCode: 201,
statusText: "Created",
data: {
    "id": 4943,
    "parent_id": 0,
    "status": "pending",
    "currency": "EUR",
    "version": "8.4.0",
    "prices_include_tax": false,
    "date_created": "2024-01-03T10:46:39",
    "date_modified": "2024-01-03T10:46:39",
    "discount_total": "0.00",
    "discount_tax": "0.00",
    "shipping_total": "0.00",
    "shipping_tax": "0.00",
    "cart_tax": "0.00",
    "total": "0.00",
    "total_tax": "0.00",
    "customer_id": 3,
    "order_key": "wc_order_ABC",
    "billing": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "Great Company GmbH",
        "address_1": "Road 1",
        "address_2": "",
        "city": "Great City",
        "state": "",
        "postcode": "98765",
        "country": "DE",
        "email": "john@great.com",
        "phone": ""
    },
    "payment_method": "b2bking-invoice-gateway",
    "payment_method_title": "Payment on account",
    "created_via": "rest-api",
    "customer_note": "",
    "date_completed": null,
    "date_paid": null,
    "number": "4943",
    "meta_data": [],
    "line_items": [
        {
            "id": 2,
            "name": "Something as a Service",
            "product_id": 3,
            "variation_id": 0,
            "quantity": 2,
            "tax_class": "",
            "subtotal": "0.00",
            "subtotal_tax": "0.00",
            "total": "0.00",
            "total_tax": "0.00",
            "taxes": [
                {
                    "id": 7,
                    "total": "0",
                    "subtotal": "0"
                }
            ],
            "meta_data": [],
            "sku": "FL10AB",
            "price": 0,
            "image": {
                "id": "",
                "src": ""
            },
            "parent_name": null
        }
    ],
    "tax_lines": [
        {
            "id": 595,
            "rate_code": "DE-MWST.-1",
            "rate_id": 7,
            "label": "MwSt.",
            "compound": false,
            "tax_total": "0.00",
            "shipping_tax_total": "0.00",
            "rate_percent": 19,
            "meta_data": []
        }
    ],
    "shipping_lines": [],
    "fee_lines": [],
    "coupon_lines": [],
    "payment_url": "https://staging.flecs.tech/checkout/order-pay/4943/?pay_for_order=true&key=wc_order_dO0JT0zZjvC7a",
    "date_created_gmt": "2024-01-03T09:46:39",
    "date_modified_gmt": "2024-01-03T09:46:39",
    "date_completed_gmt": null,
    "date_paid_gmt": null,
    "billing_period": "",
    "billing_interval": "1",
    "start_date_gmt": "2024-01-03T09:46:39",
    "trial_end_date_gmt": "",
    "next_payment_date_gmt": "",
    "last_payment_date_gmt": "",
    "cancelled_date_gmt": "",
    "end_date_gmt": "",
    "resubscribed_from": "",
    "resubscribed_subscription": "",
    "removed_line_items": [],
    "_links": {}
}

Last updated