post https://secure.fusebill.com/v1/customers/purchase/
This call is used to activate/finalize draft subscriptions/purchases on a customer who is already in status 'Active'. This can be used to activate/finalize all of their draft subscriptions/purchases, or a subset of their draft subscriptions/purchases
Path Parameters
Property | Type | Description |
---|---|---|
customerID | Integer | The Fusebill generated ID that uniquely identifies the customer |
Request Parameters
Property | Type | Description | Required |
---|---|---|---|
preview | Boolean | If true, results in no system change. Instead, a preview of the resulting invoice and charges are returned as a response. False by default | Optional |
temporarilyDisableAutoPost | Boolean | If true, then the invoice that might otherwise automatically be posted as a result of this POST will instead be created in 'draft' form. False by default | Optional |
invoiceCollectOptions | Object. Defined below | This can be used to provide special invoice collection instructions | Optional |
specificSubscriptionIds | List of Integers | A list of the specific draft subscription Fusebill IDs belonging to this customer that are to be activated | Optional |
specificPurchaseIds | List of Integers | A list of the specific draft purchase Fusebill IDs belonging to this customer that are to be finalized | Optional |
Providing no JSON body
This call can be made with no JSON body. Doing this has the effect of activating all the draft subscriptions on the customer, and finalizing all the draft purchases on the customer. Providing the
specificPurchaseIds
orspecificSubscriptionIds
tells Fusebill to activate/finalize a subset of the customer's draft subscriptions/purchases
Invoice Collect Options
Property | Type | Description |
---|---|---|
paymentMethod | Enum: { UseDefaultPaymentMethod, UseExistingPaymentMethod, UseExistingPaymentMethodAndMakeDefault, UseProvidedPaymentMethodOnce, UseProvidedPaymentMethodAndMakeDefault, UseProvidedPaymentMethodAndSave, CreateAndApplyCredit} | Controls which payment method to use |
paymentMethodId | Integer | ID of the payment method. |
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 this action and prevent the invoice from posting. |
Examples
curl –X POST https://secure.fusebill.com/v1/customers/purchase/12345 \
-H "Content-Type: application/json" \
-H "Authorization: Basic {APIKey}" \
-d "{specificSubscriptionIds:[1254352,5463542,4523453],specificPurchaseIds: [5452451,6798652,8768453]}"
//Json data
string jsonData = "{'specificSubscriptionIds':[1254352,5463542,4523453],'specificPurchaseIds': [5452451,6798652,8768453]}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/customers/purchase/12345");
//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 = {'specificSubscriptionIds':[1254352,5463542,4523453],'specificPurchaseIds':[5452451,6798652,8768453}
#Pass in your URI, Payload and Headers
r = requests.post('https://secure.fusebill.com/v1/customers/purchase/12345', data=json.dumps(payload), headers=headers)
print(r.content)
{
"specificSubscriptionIds": [
1254352,
5463542,
4523453
],
"specificPurchaseIds": [
5452451,
6798652,
8768453
]
}
{
"preview": false,
"temporarilyDisableAutoPost": false,
"invoiceCollectOptions": {
"paymentMethod": "UseProvidedPaymentMethodAndSave",
"useAnyAvailableFundsFirst": false,
"creditCard": {
"cardNumber": 1234123412341234,
"expirationMonth": 2,
"expirationYear": 23,
"cvv": 123,
"firstName": "Karen",
"lastName": "Wood",
"address1": "10 Dodge St",
"address2": "",
"city": "Columbia",
"stateId": 1,
"countryId": 124,
"source": "Manual",
"postalZip": "V9V 9V9",
"customerId": 12345678
},
"achCard": null,
"rollbackOnFailedPayment": true
},
"specificSubscriptionIds": [
1254352,
5463542,
4523453
],
"specificPurchaseIds": [
5452451,
6798652,
8768453
]
}
Response
{
"invoicePreview": {
"draftCharges": [
{
"transactionId": 0,
"chargeTypeId": null,
"transactionType": "Charge",
"quantity": 1.0,
"unitPrice": 250.00,
"amount": 250.00,
"taxableAmount": 250.00,
"subscriptionPeriodId": 0,
"draftInvoiceId": 0,
"name": "Premium Access",
"description": null,
"effectiveTimestamp": "2020-01-23T17:38:07.0001004Z",
"proratedUnitPrice": null,
"startServiceDate": "2020-01-23T00:00:00",
"endServiceDate": "2020-02-22T00:00:00",
"rangeQuantity": null,
"draftDiscount": null,
"draftDiscounts": [],
"status": "Active",
"productItems": null,
"canProrateCharge": false,
"postable": true,
"subscriptionProductId": 25714915,
"purchaseId": null,
"productId": 25044592,
"draftChargeTiers": [],
"id": 0,
"uri": null
},
{
"transactionId": 0,
"chargeTypeId": null,
"transactionType": "Charge",
"quantity": 0.0,
"unitPrice": 10.00,
"amount": 0.00,
"taxableAmount": 0.00,
"subscriptionPeriodId": 0,
"draftInvoiceId": 0,
"name": "GPS device",
"description": null,
"effectiveTimestamp": "2020-01-23T17:38:07.0001004Z",
"proratedUnitPrice": null,
"startServiceDate": "2020-01-23T00:00:00",
"endServiceDate": "2020-01-23T00:00:00",
"rangeQuantity": null,
"draftDiscount": null,
"draftDiscounts": [],
"status": "Active",
"productItems": null,
"canProrateCharge": false,
"postable": true,
"subscriptionProductId": 25714913,
"purchaseId": null,
"productId": 25188589,
"draftChargeTiers": [],
"id": 0,
"uri": null
}
],
"subtotal": 250.00,
"total": 250.00,
"draftTaxes": [],
"totalTaxes": 0.00,
"totalDiscount": 0.0,
"poNumber": null,
"effectiveTimestamp": "0001-01-01T00:00:00",
"status": "Ready",
"draftChargeGroups": [
{
"name": "bronze",
"description": "the bronze plan",
"reference": null,
"subscriptionId": 12092276,
"draftCharges": [
{
"transactionId": 0,
"chargeTypeId": null,
"transactionType": "Charge",
"quantity": 1.0,
"unitPrice": 250.00,
"amount": 250.00,
"taxableAmount": 250.00,
"subscriptionPeriodId": 0,
"draftInvoiceId": 0,
"name": "Premium Access",
"description": null,
"effectiveTimestamp": "2020-01-23T17:38:07.0001004Z",
"proratedUnitPrice": null,
"startServiceDate": "2020-01-23T00:00:00",
"endServiceDate": "2020-02-22T00:00:00",
"rangeQuantity": null,
"draftDiscount": null,
"draftDiscounts": [],
"status": "Active",
"productItems": null,
"canProrateCharge": false,
"postable": true,
"subscriptionProductId": 25714915,
"purchaseId": null,
"productId": 25044592,
"draftChargeTiers": [],
"id": 0,
"uri": null
},
{
"transactionId": 0,
"chargeTypeId": null,
"transactionType": "Charge",
"quantity": 0.0,
"unitPrice": 10.00,
"amount": 0.00,
"taxableAmount": 0.00,
"subscriptionPeriodId": 0,
"draftInvoiceId": 0,
"name": "GPS tracker",
"description": null,
"effectiveTimestamp": "2020-01-23T17:38:07.0001004Z",
"proratedUnitPrice": null,
"startServiceDate": "2020-01-23T00:00:00",
"endServiceDate": "2020-01-23T00:00:00",
"rangeQuantity": null,
"draftDiscount": null,
"draftDiscounts": [],
"status": "Active",
"productItems": null,
"canProrateCharge": false,
"postable": true,
"subscriptionProductId": 25714913,
"purchaseId": null,
"productId": 25188589,
"draftChargeTiers": [],
"id": 0,
"uri": null
}
]
}
],
"notes": null,
"shippingInstructions": null,
"openingArBalance": 250.0000,
"closingArBalance": 500.0000,
"creditFromAvailableFunds": 0.0
}
}
{
"ErrorId": 0,
"HttpStatusCode": 400,
"Errors": [
{
"Key": "Api Error",
"Value": "Unable to complete purchase, there was nothing to purchase for this customer."
}
]
}