Patch Plan Products

The PATCH Plan Products endpoint is used to update the pricing on multiple plan products, all belonging to the same plan.

Request Parameters

PropertyTypeDescriptionRequired
planIdNumberThe Fusebill generated ID uniquely identifying the plan the plan products belong to.Yes
planProductsList of objects. Defined belowThe list of plan products containing price changes, all of which must belong to the specified planIdYes

Plan Products Object

PropertyTypeDescription
orderToCashCyclesList of objects. Defined belowA 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.
idNumberThe Fusebill generated ID which uniquely identifies this plan product

Order To Cash Cycle Object

PropertyType
pricingModelObject. Defined belowAn object which defines the pricing type and ranges
idNumberThe Fusebill generated ID which uniquely identifies this order to cash cycle

Pricing Model Object

PropertyTypeDescription
pricingModelTypeEnum:{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.
quantityRangesList of objects. Defined belowThis array contains the pricing for various ranges. The quantity ranges must cover from zero to infinity with no gaps.

Quantity Range Object

PropertyTypeDescription
minDecimalThe minimum number for this range.
maxDecimalThe maximum quantity for this range. Null is interpreted to mean infinity
pricesList of objects. Defined belowA price must be provided for each currency

Price Object

PropertyTypeDescription
amountDecimalThe 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.
conditionAmountDecimalRelevant 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
variableAmountDecimalRelevant only for Formula type pricing. This is the percentage of the opening balance to charge for.
currency3 character ISO currency codeThe 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"
        }
    ]
}
Language
Authorization