patch https://secure.fusebill.com/v1/planProducts
The PATCH Plan Products endpoint is used to update the pricing on multiple plan products, all belonging to the same plan.
Request Parameters
Property | Type | Description | Required |
---|---|---|---|
planId | Number | The Fusebill generated ID uniquely identifying the plan the plan products belong to. | Yes |
planProducts | List of objects. Defined below | The list of plan products containing price changes, all of which must belong to the specified planId | Yes |
Plan Products Object
Property | Type | Description |
---|---|---|
orderToCashCycles | List of objects. Defined below | A list of order to cash cycles to overwrite. There is a one to one relationship between order to cash cycle and plan frequency. The order to cash cycle contains a pricing model, which specifies how the plan product is to be priced for the specific plan frequency. |
id | Number | The Fusebill generated ID which uniquely identifies this plan product |
Order To Cash Cycle Object
Property | Type | |
---|---|---|
pricingModel | Object. Defined below | An object which defines the pricing type and ranges |
id | Number | The Fusebill generated ID which uniquely identifies this order to cash cycle |
Pricing Model Object
Property | Type | Description |
---|---|---|
pricingModelType | Enum:{Standard, Tiered, StairStep, Formula, Volume} | Dictates how the price is calculated using the quantity. This is for the subscription product that is based on this plan product on this plan frequency. |
quantityRanges | List of objects. Defined below | This array contains the pricing for various ranges. The quantity ranges must cover from zero to infinity with no gaps. |
Quantity Range Object
Property | Type | Description |
---|---|---|
min | Decimal | The minimum number for this range. |
max | Decimal | The maximum quantity for this range. Null is interpreted to mean infinity |
prices | List of objects. Defined below | A price must be provided for each currency |
Price Object
Property | Type | Description |
---|---|---|
amount | Decimal | The amount of the price, measured in the provided currency, and to be used for customers with that currency. When using Formula type pricing, this is the minimum charge. |
conditionAmount | Decimal | Relevant only for Formula type pricing. This is the threshold for how large the invoice opening balance must be in order for a charge to be generated |
variableAmount | Decimal | Relevant only for Formula type pricing. This is the percentage of the opening balance to charge for. |
currency | 3 character ISO currency code | The currency this price is for. |
Examples
curl -X PATCH "https://secure.fusebill.com/v1/planProducts" \
-H "Content-Type: application/json" \
-H "Authorization: Basic {APIKey}" \
-d "{planId:17211,planProducts:[{orderToCashCycles:[{pricingModel:'Standard',quantityRanges:[{min:0.0,max:null,prices:[{amount:9.99,currency:'CAD'}],id:5678}],id:1234}]}"
//Json Payload
string jsonData = "{planId:17211,planProducts:[{orderToCashCycles:[{pricingModel:'Standard',quantityRanges:[{min:0.0,max:null,prices:[{amount:9.99,currency:'CAD'}],id:5678}],id:1234}]}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/planProducts");
//Add Content type
request.ContentType = "application/json";
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic "+apiKey);
//Set request method
request.Method = "PATCH";
//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 dictionary to the Payload parameter
payload = {'planId':17211,'planProducts':[{'orderToCashCycles':[{'pricingModel':'Standard','quantityRanges':[{'min':0.0,'max':null,'prices':[{'amount':9.99,'currency':'CAD'}],'id':5678}],'id':1234}]}
#Pass in your URI, Payload and Headers
r = requests.patch('https://secure.fusebill.com/v1/planProducts', data=json.dumps(payload), headers=headers)
print(r.content)
{
"planId": 17211,
"planProducts": [
{
"orderToCashCycles": [
{
"pricingModel": {
"pricingModelType": "Standard",
"quantityRanges": [
{
"min": 0.0,
"max": null,
"prices": [
{
"amount": 90.99,
"conditionAmount": null,
"variableAmount": null,
"currency": "CAD"
},
{
"amount": 80.99,
"conditionAmount": null,
"variableAmount": null,
"currency": "USD"
}
]
}
]
},
"id": 1124811
}
],
"id": 61182
}
]
}
Response
[
{
"status": "Active",
"productId": 46737,
"planId": 17211,
"productCode": "access",
"productName": "Access",
"productStatus": "Active",
"productDescription": "premium access",
"productType": "RecurringService",
"productGLCode": "1111",
"quantity": 1.0,
"maxQuantity": null,
"isRecurring": false,
"isFixed": false,
"isOptional": true,
"isIncludedByDefault": false,
"isTrackingItems": false,
"chargeAtSubscriptionActivation": true,
"orderToCashCycles": [
{
"planFrequencyId": 22177,
"planProductId": 61182,
"numberOfIntervals": 1,
"interval": "Monthly",
"chargeModels": [
{
"chargeModelType": "Signup",
"chargeTimingType": "StartOfPeriod",
"prorationGranularity": null,
"prorateOnPositiveQuantity": false,
"prorateOnNegativeQuantity": false,
"reverseChargeOnNegativeQuantity": false,
"id": 112481,
"uri": null
},
{
"chargeModelType": "Lifetime",
"chargeTimingType": "Immediate",
"prorationGranularity": null,
"prorateOnPositiveQuantity": false,
"prorateOnNegativeQuantity": false,
"reverseChargeOnNegativeQuantity": false,
"id": 112481,
"uri": null
}
],
"customFields": [
{
"key": "alphaB",
"friendlyName": "alphaB",
"dataType": "String",
"defaultValue": "123"
}
],
"remainingInterval": null,
"groupQuantityChangeCharges": false,
"planProductPriceUplifts": [],
"customServiceDateNumberOfIntervals": 0,
"customServiceDateInterval": "Periods",
"customServiceDateProjection": "Future",
"upliftPriorToRecharge": false,
"includingInitialCharge": false,
"earningInterval": "",
"earningNumberOfIntervals": null,
"earningTimingInterval": "EarnImmediately",
"earningTimingType": "StartOfInterval",
"pricingModel": {
"pricingModelType": "Standard",
"quantityRanges": [
{
"min": 0.0,
"max": null,
"prices": [
{
"amount": 80.99,
"conditionAmount": null,
"variableAmount": null,
"currency": "USD",
"id": 160374,
"uri": null
},
{
"amount": 90.99,
"conditionAmount": null,
"variableAmount": null,
"currency": "CAD",
"id": 160594,
"uri": null
}
],
"id": 129312,
"uri": null
}
],
"id": 112481,
"uri": null
},
"id": 112481,
"uri": null
}
],
"resetType": "Never",
"planProductUniqueId": 60916,
"sortOrder": 3,
"generateZeroDollarCharge": false,
"id": 61182,
"uri": "https://secure.fusebill.com/v1/planproducts/61182"
}
]
{
"ErrorId": 0,
"HttpStatusCode": 400,
"Errors": [
{
"Key": "Api Error",
"Value": "Unable to find order to cash cycle 1124811 belonging to plan product 61182"
}
]
}