post https://secure.fusebill.com/v1/SubscriptionProductItems
This function creates a new tracked item on a subscription product.
URL Parameters
Property | Type | Description |
---|---|---|
showZeroDollarCharges | Boolean | If true, then the invoice that might be generated by this request will show zero dollar charges as line items. False by default. |
temporarilyDisableAutoPost | Boolean | If true, then the invoice that might otherwise automatically be posted by increasing the quantity of tracked items on the subscription product will instead be created in 'draft' form. False by default |
preview | Boolean | If true, results in no system change or item creation. Instead, a preview of the item and the resulting invoice and charges are returned as a response. False by default |
Request Parameters
Property | Type | Description | Required |
---|---|---|---|
reference | String | The unique identifier for this tracked item. This uniqueness is enforced by Fusebill across all tracked items for that product, not just tracked items on the given subscription product. [Max Length: 255 characters] | Yes |
subscriptionProductId | Integer | The Fusebill generated unique ID for the subscription product which is tracking enabled and with which you want the new tracked item associated | Yes |
name | String | An optional field for storing custom data, intended to be the name of the item. [Max Length 100 characters] | Optional |
description | String | An optional field for storing custom data, intended to be a description of the item. [Max Length: 255 characters] | Optional |
invoiceCollectOptions | Object. Defined below | This can be used to provide special invoice collection instructions for the invoice which may be generated by this API call | Optional |
Invoice collection options
Property | Type | Description |
---|---|---|
paymentMethod | Enum: { UseDefaultPaymentMethod, UseExistingPaymentMethod, UseExistingPaymentMethodAndMakeDefault, UseProvidedPaymentMethodOnce, UseProvidedPaymentMethodAndMakeDefault, UseProvidedPaymentMethodAndSave, CreateAndApplyCredit} | Controls which payment method to use |
paymentMethodId | Integer | The Fusebill generated ID of the payment method. Provide this only if paymentMethod is "UseExistingPaymentMethod" or "UseExistingPaymentMethodAndMakeDefaul" |
useAnyAvailableFundsFirst | Boolean | Controls whether available funds on the customer entity should be used first. |
creditCard | Object | See credit card creation parameters as outlined in Create Credit Card Payment Method |
achCard | Object | See ACH card creation parameters as outlined in Create ACH Payment Method |
rollbackOnFailedPayment | Boolean | If payment fails, Fusebill can undo the purchase completion and prevent the invoice from posting. |
Request Examples
POST https://secure.fusebill.com/v1/SubscriptionProductItems
Authorization: Basic {{apikey}}
Content-Type: application/json
{
"reference" : "LiscenceKeyHere",
"name" : "Basic License",
"description" : "provides basic access",
"subscriptionProductID": 1234567
}
//Adds a new tracked item to subscription product 1234567 with the
//given values for reference, name, and description
POST https://secure.fusebill.com/v1/SubscriptionProductItems?preview=true
Authorization: Basic {{apikey}}
Content-Type: application/json
{
"reference" : "LiscenceKeyHere",
"name" : "Basic License",
"description" : "provides basic access",
"subscriptionProductID": 1234567
}
//Does NOT add a new tracked item to subscription product 1234567 with the
//given values for reference, name, and description.
//Instead it previews the item and the invoice that would be generated.
POST https://secure.fusebill.com/v1/SubscriptionProductItems?temporarilyDisableAutoPost=true
Authorization: Basic {{apikey}}
Content-Type: application/json
{
"reference" : "LiscenceKeyHere",
"name" : "Basic License",
"description" : "provides basic access",
"subscriptionProductID": 1234567
}
//Adds a new tracked item to subscription product 1234567 with the
//given values for reference, name, and description.
//The invoice this might have generated will be draft.
Examples
curl -X POST "https://secure.fusebill.com/v1/SubscriptionProductItems" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere" \
-d "{reference:'LiscenceKeyHere',name:'Basic License',description: 'provides basic access',subscriptionProductId:1234567}"
//Json data for payload
string jsonData = "{'reference':'LiscenceKeyHere','name':'Basic License','description': 'provides basic access','subscriptionProductId':1234567}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/SubscriptionProductItems ");
//Add Content type
request.ContentType = "application/json";
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic "+apiKey);
//Set request method
request.Method = "POST";
//Add the json data to request
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(jsonData);
streamWriter.Flush();
streamWriter.Close();
}
//Perform the request
var httpResponse = (HttpWebResponse)request.GetResponse();
//Record the response from our request
var result = "";
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
result = streamReader.ReadToEnd();
}
#Import library JSON
import json
#Import library Requests
import requests
#Pass in a dictionary to the Headers parameter
headers = {'Authorization' : 'Basic {APIKey}', 'Content-Type' : 'application/json'}
#Pass in a dict to the Payload parameter
payload = {'reference':'LiscenceKeyHere','name': 'Basic License', 'description':'provides basic access' , 'subscriptionID': 1234567}
#Pass in your URI, Payload and Headers
r = requests.post('https://secure.fusebill.com/v1/SubscriptionProductItems , data=json.dumps(payload), headers=headers)
print(r.content)
{
"reference": "LiscenceKeyHere",
"name": "Basic License",
"description": "provides basic access",
"subscriptionProductID": 1234567
}
Response
{
"reference": 123459651622156,
"name": "Thermostat",
"description": "MODEL MC1-0092",
"subscriptionProductId": 2334138,
"subscriptionId": 305425,
"customerId": 643539,
"productId": 46818,
"status": "Active",
"createdDate": "2019-11-01T11:51:26",
"modifiedDate": "2019-11-01T11:51:26.77",
"id": 242386,
"uri": "https://secure.fusebill.com/v1/subscriptionProductItems/242386"
}
{
"ErrorId": 0,
"HttpStatusCode": 400,
"Errors": [
{
"Key": "Api Error",
"Value": "Duplicate product items reference. The following references are duplicated: 123"
}
]
}