Update Purchase

This function is used to modify a purchase before it is finalized and completed.

Request Parameters

PropertyTypeDescription
idIntegerThis is the purchase ID which uniquely identifies this purchase.
quantityDecimalThe quantity being purchased. Used by the pricing model and price ranges to calculate the overall price. If the purchase is using tracked quantities, leave this null
targetOrderQuantityDecimalThe number of tracked items which must be on this purchase in order to be considered fulfilled. If this is not met, the purchase cannot be finalized. Cannot be used for purchases which are not tracking items.
nameStringThe name of the purchase. [Max Length: 2000]
descriptionStringThe description of the purchase. [Max Length: 2000]
overridePriceRangesList of objects. Defined belowThe price ranges used to determine the amount to charge. For the standard pricing model, this is a single range from 0 to infinity with a single price. This is an override just for this purchase.
pricingModelTypeEnum: {Tiered, Volume, Standard, Stairstep}Can be used to override the pricing model being used just for this purchase.
earningSettingsObject. Defined belowControls how this purchase earns
netsuiteLocationIdStringThe location of this purchase in NetSuite. [Max Length: 100 characters]

Override Price Ranges Fields

PropertyTypeDescription
minDecimalThe lower bound of the range
maxDecimalThe upper bound of the range. Null is interpreted as infinity
amountDecimalThe price for this range

Earning Settings Object

PropertyTypeDescription
earningIntervalEnum: {Monthly, Yearly}Indicates whether the custom earning period (if a custom earning period is being used) is measured in years or months
earningNumberOfIntervalsIntegerThe number of earningIntervals that constitute the period this purchase earns over
earningTimingIntervalEnum:{Daily, Monthly, Yearly, Interval, DoesNotEarn, EarnImmediately}Indicates how to divide the custom period if a custom period is being used, indicates the purchase does not earn, or indicates that the purchase earns immediately
earningTimingTypeEnum:{StartOfInterval, EndOfInterval, DoesNotEarn}Indicates where in the interval the earning occurs, if custom earning periods are being used
Examples
curl -X PUT "https://secure.fusebill.com/v1/Purchases" \
	-H "Content-Type: application/json" \
	-H "Authorization: Basic {APIKey}" \
	-d "{id:{PurchaseId},customerId:{CustomerId},productId:{ProductId},name:'purchase1updated'}"
//Json Payload
string jsonData = "{id:{PurchaseId},customerId:{CustomerId},productId:{ProductId},name:'purchase1updated'}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/Purchases");
//Add Content type
request.ContentType = "application/json";
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic " + apiKey);
//Set request method
request.Method = "PUT";
//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 = 
{"customerId":{id},"productId":{id},"name":"purchaseUpdated","description":None,"status":"Draft","quantity":1,"isTrackingItems":"false","pricingModelType
":"Standard","customFields":[],"discounts":[],"priceRanges":[{"min":0.000000,"max":None,"amount":99.000000}],"productItems":[],"couponCodes":
[],"earningSettings":
{"earningInterval":"","earningNumberOfIntervals":None,"earningTimingInterval":"EarnImmediately","earningTimingType":"StartOfInterval"},"id":{id},"uri":"https://stg-secure.fusebill.com/v1/purchases/{id}"}
#Pass in your URI, Payload and Headers
r = requests.put('https://secure.fusebill.com/v1/purchases', data=json.dumps(payload), headers=headers)
print(r.content)
{
    "customerId": 12762177,
    "code": "device",
    "effectiveTimestamp": "2019-11-11T19:39:55",
    "taxableAmount": 15,
    "amount": 15,
    "modifiedTimestamp": "2019-11-11T19:40:07.963",
    "salesforceId": "b045a250231VC4RCAW",
    "netsuiteLocationId": "123",
    "productId": 25309384,
    "name": "Fitness Tracker",
    "description": "Model 5000",
    "status": "Purchased",
    "quantity": 1,
    "targetOrderQuantity": null,
    "isTrackingItems": false,
    "pricingModelType": "Standard",
    "customFields": [],
    "discounts": [],
    "priceRanges": [
      {
        "min": 0,
        "max": null,
        "amount": 15,
        "conditionAmount": null,
        "variableAmount": null
      }
    ],
    "productItems": [],
    "couponCodes": [],
    "earningSettings": {
      "earningInterval": "",
      "earningNumberOfIntervals": null,
      "earningTimingInterval": "EarnImmediately",
      "earningTimingType": "StartOfInterval"
    },
    "id": 1616831,
    "uri": "https://secure.fusebill.com/v1/Purchases/1616831"
  }
Response
{
    "customerId": 12762177,
    "code": "device",
    "effectiveTimestamp": "2019-11-11T19:39:55",
    "taxableAmount": 15,
    "amount": 15,
    "modifiedTimestamp": "2019-11-11T19:40:07.963",
    "salesforceId": "b045a250231VC4RCAW",
    "netsuiteLocationId": "123",
    "productId": 25309384,
    "name": "Fitness Tracker",
    "description": "Model 5000",
    "status": "Purchased",
    "quantity": 1,
    "targetOrderQuantity": null,
    "isTrackingItems": false,
    "pricingModelType": "Standard",
    "customFields": [],
    "discounts": [],
    "priceRanges": [
      {
        "min": 0,
        "max": null,
        "amount": 15,
        "conditionAmount": null,
        "variableAmount": null
      }
    ],
    "productItems": [],
    "couponCodes": [],
    "earningSettings": {
      "earningInterval": "",
      "earningNumberOfIntervals": null,
      "earningTimingInterval": "EarnImmediately",
      "earningTimingType": "StartOfInterval"
    },
    "id": 1616831,
    "uri": "https://secure.fusebill.com/v1/Purchases/1616831"
  }
{
    "ErrorId": 0,
    "HttpStatusCode": 400,
    "Errors": [
        {
            "Key": "purchase.Name",
            "Value": "The Name field is required."
        }
    ]
}
Language
Authorization