Creating a Checkout Page

One of the most common tasks a developer will perform using the Fusebill API is create a billing entity in the Fusebill system, so that it can be properly charged for services.
At a high level this requires the input of the following 3 pieces of information:
- Who the customer is.
- What they want to buy.
- How they want to Pay.
The following tutorial identifies the inventory of API calls which may be required to get this information properly captured in the Fusebill system.
Step A - Get Plans (Optional)
You will start out by getting the plans you are selling so your customer can pick what they would like to purchase, this step assumes you have created plans in your Fusebill account. If you have not created any plans, refer to the create plans documentation located here.
Get Plans
This is an optional step to populate a plan selection screen. The important information to gather is the specific Plan Frequency IDs that you want to offer on your registration page. Alternatively, this information can be hard-coded. If your catalog doesn't change very often, much of this information can be cached in order to avoid excess API usage and speed up the process.
Sample Request
curl -X GET "https://secure.fusebill.com/v1/Plans/?query=status:Active" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere"
Sample Response
[
{
"code":"BSC2",
"name":"Basic",
"reference":null,
"description":"Basic Monthly Services for Kennedy Consulting",
"longdescription":"this is the entry level subscription for Kennedy Consulting",
"status":"Active",
"modificationTimestamp":"0001-01-01T00:00:00",
"planFrequencies":[
{
"planRevisionId":247,
"numberOfIntervals":1,
"interval":"Monthly",
"numberOfSubscriptions":3,
"status":"Active",
"setupFees":[
{
"amount":10.000000,
"currency":"USD",
"id":0,
"uri":null
}
],
"charges":[
{
"amount":2.000000,
"currency":"USD",
"id":0,
"uri":null
}
],
"isProrated":false,
"prorationGranularity":null,
"planFrequencyUniqueId":114,
"remainingInterval":null,
"id":114,
"uri":null
}
],
"autoApplyChanges":false,
"id":114,
"uri":"https://secure.fusebill.com/v1/Plans/114"
}
]
Step 1 - Create Customer and Customer Details
The first step to entering a potential new subscriber is to create the customer entity in the Fusebill system. Remember, a customer in the Fusebill system represents a unique billing entity. In this step, we are entering “Who” the customer is by submitting data we capture from the user. The flexibility of the Fusebill system allows you to capture as much, or as little, information as would like from potential sign ups. Customer information is broken down into 3 areas, each with their own individual API call.
- Main Customer Contact information – POST Customer (mandatory)
- Customer Billing Settings – POST CustomerBilingProfile (optional)
- Customer Address Information – POST Addresses (optional)
STEP 1A - Create Customer
This first call will capture customer tombstone data (Name, Company, Email, numbering, etc..) and create a customer entity in the Fusebill system in draft status. It is mandatory to create a customer entity but you do not need to set all of the fields. Every customer created will be assigned a unique FusebillID but Fusebill does recommend that you also set at least one of Name, Company name or Reference in order to uniquely identify the customer. Fusebill also strongly recommends that you record the created FusebillID into your system as it will be needed for a majority of the subsequent API calls you will make.
Example Request
curl -X POST "https://secure.fusebill.com/v1/customers" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere" \
-d "{title:'Mr',firstName:'John',lastName:'Smith',companyName:'Acme Inc.'}"
//Json Payload
string jsonData = "{'firstName':'John', 'lastName':'Doe'}";
//Setup API key
string apiKey = "your api key goes here";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://stg-secure.fusebill.com/v1/customers");
//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();
}
It is mandatory that a customer entity be created in draft status so it can act as the container for holding the desired subscriptions, payment methods, addresses, etc., in order to leverage the Fusebill system to provide an accurate checkout amount.
Example Response
{
"firstName":"John",
"middleName":null,
"lastName":"Smith",
"companyName":"Acme Inc.",
"suffix":null,
"primaryEmail":null,
"primaryPhone":null,
"secondaryEmail":null,
"secondaryPhone":null,
"title":"Mr",
"reference":null,
"status":"Draft",
"customerAccountStatus":"Good",
"currency":"USD",
"customerReference":{
"reference1":null,
"reference2":null,
"reference3":null,
"salesTrackingCodes":[
],
"id":169456,
"uri":"https://secure.fusebill.com/v1/customers/169456"
},
"customerAcquisition":{
"adContent":null,
"campaign":null,
"keyword":null,
"landingPage":null,
"medium":null,
"source":null,
"id":169456,
"uri":"https://secure.fusebill.com/v1/customers/169456"
},
"monthlyRecurringRevenue":0.0,
"netMonthlyRecurringRevenue":0.0,
"salesforceId":null,
"salesforceAccountType":null,
"salesforceSynchStatus":"Enabled",
"netsuiteId":null,
"netsuiteCustomerType":"",
"portalUserName":null,
"parentId":null,
"id":169456,
"uri":"https://secure.fusebill.com/v1/customers/169456"
}
STEP 1B - Update Customer Billing Settings (Optional)
GET https://secure.fusebill.com/v1/customerbillingsetting
PUT https://secure.fusebill.com/v1/customerbillingsetting
This call is purely optional and is used if you need to modify the default billing settings used for new customers that are configured in your account. In order to do this, you must first retrieve the current customer billing settings via a GET call, apply any modifications and resubmit the full customer billing settings via a PUT call.
Sample GET Request
curl -X GET "https://secure.fusebill.com/v1/customerbillingsetting/YourCustomerIDHere" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere"
/path parameter, Fusebill Id which corresponds to the Id returned by Get Customer
int pathParameter = Customer Id;
//Setup API key
string apiKey = "Your Api Key Here";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://stg-secure.fusebill.com/v1/customerbillingsetting/"+pathParameter);
//Add Content type
request.ContentType = "application/json";
request.ContentLength = 0;
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic "+apiKey);
//Set request method
request.Method = "GET";
//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();
}
Sample Response
{
"invoiceDay": null,
"term": "Net0",
"interval": "Monthly",
"autoCollect": null,
"rechargeType": "",
"rechargeThresholdAmount": null,
"rechargeTargetAmount": null,
"statusOnThreshold": null,
"autoPostDraftInvoice": null,
"hasPaymentMethod": false,
"customerGracePeriod": null,
"gracePeriodExtension": null,
"standingPoNumber": null,
"billingPeriodConfigurations": [
],
"acquisitionCost": 0,
"showZeroDollarCharges": null,
"taxExempt": false,
"useCustomerBillingAddress": true,
"taxExemptCode": null,
"avalaraUsageType": null,
"vatIdentificationNumber": null,
"customerServiceStartOption": "",
"rollUpTaxes": null,
"rollUpDiscounts": null,
"trackedItemDisplay": null,
"customerBillingStatementSetting": {
"option": null,
"type": null,
"interval": null,
"day": null,
"month": null,
"trackedItemDisplay": null
},
"id": 84770,
"uri": null
}
Sample PUT Request
curl -X PUT "https://secure.fusebill.com/v1/customerbillingsetting" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere" \
-d "{id:YourCustomerIdHere,invoiceDay:null,term:'Net0',interval:'Monthly',autoCollect:null,rechargeType:'',rechargeThresholdAmount:null,rechargeTargetAmount:null,statusOnThreshold:null,autoPostDraftInvoice:null,hasPaymentMethod:false,customerGracePeriod:null,gracePeriodExtension:null,standingPoNumber:null,billingPeriodConfigurations:[],acquisitionCost:0,showZeroDollarCharges:null,taxExempt:false,useCustomerBillingAddress:true,taxExemptCode:null,avalaraUsageType:null,vatIdentificationNumber:null,customerServiceStartOption:'',rollUpTaxes:null,rollUpDiscounts:null,trackedItemDisplay:null,customerBillingStatementSetting:{option:null,type:null,interval:null,day:null,month:null,trackedItemDisplay:null}}"
//Json data, Fusebill Id which corresponds to the customerId Field
string jsonData ="{id:CustomerIdHere,invoiceDay:null,term:'Net0',interval:'Monthly',autoCollect:null,rechargeType:'',rechargeThresholdAmount:null,rechargeTargetAmount:null,statusOnThreshold:null,autoPostDraftInvoice:null,hasPaymentMethod:false,customerGracePeriod:null,gracePeriodExtension:null,standingPoNumber:null,billingPeriodConfigurations:[],acquisitionCost:0,showZeroDollarCharges:null,taxExempt:false,useCustomerBillingAddress:true,taxExemptCode:null,avalaraUsageType:null,vatIdentificationNumber:null,customerServiceStartOption:'',rollUpTaxes:null,rollUpDiscounts:null,trackedItemDisplay:null,customerBillingStatementSetting:{option:null,type:null,interval:null,day:null,month:null,trackedItemDisplay:null}}";
//Setup API key
string apiKey = "Your Api Key Here";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://stg-secure.fusebill.com/v1/customerbillingsetting");
//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();
}
Sample Response
{
"invoiceDay": null,
"term": "Net0",
"interval": "Monthly",
"autoCollect": null,
"rechargeType": "",
"rechargeThresholdAmount": null,
"rechargeTargetAmount": null,
"statusOnThreshold": null,
"autoPostDraftInvoice": null,
"hasPaymentMethod": false,
"customerGracePeriod": null,
"gracePeriodExtension": null,
"standingPoNumber": null,
"billingPeriodConfigurations": [
],
"acquisitionCost": 0,
"showZeroDollarCharges": null,
"taxExempt": false,
"useCustomerBillingAddress": true,
"taxExemptCode": null,
"avalaraUsageType": null,
"vatIdentificationNumber": null,
"customerServiceStartOption": "",
"rollUpTaxes": null,
"rollUpDiscounts": null,
"trackedItemDisplay": null,
"customerBillingStatementSetting": {
"option": null,
"type": null,
"interval": null,
"day": null,
"month": null,
"trackedItemDisplay": null
},
"id": 84770,
"uri": null
}
STEP 1C - Create Billing and Shipping Address (Optional)
In many cases, you will want to capture billing or shipping address information for your customers. In addition to being rendered on invoices, this information is also used to calculate taxes and might be necessary if your service requires shipping goods to your customer.
Sample Request
curl -X POST "https://secure.fusebill.com/v1/Addresses" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere" \
-d "{customerAddressPreferenceId:YourCustomerIdHere,companyName:'Fusebill',line1:'232 Herzberg Road',line2:'Suite 203',countryId:124,country:'Canada',stateId:9,state:'Ontario',city:'Kanata',postalZip:'K2K 2A1',addressType:'Billing'}"
//Json data, Fusebill Id which corresponds to the customerId Field
string jsonData ="{customerAddressPreferenceId:CustomerIdHere,companyName:'Fusebill',line1:'232 Herzberg Road',line2:'Suite 203',countryId:124,country:'Canada',stateId:9,state:'Ontario',city:'Kanata',postalZip:'K2K 2A1',addressType:'Billing'}";
//Setup API key
string apiKey = "Your Api Key Here";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://stg-secure.fusebill.com/v1/Addresses");
//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();
}
Sample Response
{
"customerAddressPreferenceId": 84636,
"companyName": "DarkSide",
"line1": "117 Waba Road",
"line2": null,
"countryId": 124,
"country": "Canada",
"stateId": 9,
"state": "Ontario",
"city": "Pakenham",
"postalZip": "K0A2X0",
"addressType": "Billing",
"id": 63406,
"uri": "https://secure.fusebill.com/v1/addresses/63406"
}
Step 2 - Creating a Subscription for a Customer
Now that you have created a Fusebill Customer in “Draft” status, you can add subscriptions to the customer. Customers can be given subscriptions to a specific frequency of a plan from your account’s catalog. When you first create a subscription, it will also be created in status “Draft”. This provides the opportunity to modify the subscription by including/excluding products or modifying the quantity in specific products.
Create Subscription
As mentioned in Step A, the important information to submit is the specific plan frequency IDs. Alternatively, this information can be hard-coded
Sample Request
curl -X POST "https://secure.fusebill.com/v1/subscriptions" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere" \
-d "{customerid:YourCustomerIdHere,code:'YourPlanCodeHere',name:'YourPlanNameHere',reference:null,planFrequencyId:YourPlanFrequencyIdHere}"
//Json Payload
string jsonData = "{customerid:YourCustomerIdHere,code:'YourPlanCodeHere',name:'YourPlanNameHere',reference:null,planFrequencyId:YourPlanFrequencyIdHere}";
//Setup API key
string apiKey = "YourAPIKeyHere";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://stg-secure.fusebill.com/v1/subscriptions");
//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();
}
Sample Response
{
"customerId":172677,
"planFrequency":{
"planRevisionId":122453,
"numberOfIntervals":1,
"interval":"Monthly",
"numberOfSubscriptions":1,
"status":"Active",
"setupFees":[
{
"amount":10.0,
"currency":"USD",
"id":0,
"uri":null
}
],
"charges":[
{
"amount":2.0,
"currency":"USD",
"id":0,
"uri":null
}
],
"isProrated":false,
"prorationGranularity":null,
"planFrequencyUniqueId":114,
"remainingInterval":null,
"id":114,
"uri":null
},
"planCode":"BSC2",
"planName":"Basic",
"planDescription":"Basic Monthly Services for Kennedy Consulting",
"planReference":null,
"status":"Cancelled",
"reference":null,
"subscriptionOverride":null,
"hasPostedInvoice":true,
"createdTimestamp":"2017-01-11T18:35:37",
"activatedTimestamp":null,
"provisionedTimestamp":"2017-01-11T19:07:57",
"nextPeriodStartDate":null,
"scheduledActivationTimestamp":"2017-02-01T05:00:00",
"subscriptionProducts":[
Step 3 - Configure a Subscription for the Customer
Once a subscription exists on a customer it can be customized to match the customer’s selections (if desired). To modify a subscription, GET the subscription, modify settings, perform a PUT on the subscription with the full JSON of the subscription.
Common subscription modifications include:
- Setting high level subscription parameters by modifying the subscription name, description or reference to control how the subscription is rendered on invoices.
- Setting subscription contract periods or expiry periods would also fall into this category.
- Setting individual subscription products by modifying settings such as Quantity, Pricing, Inclusion, Discounts, etc..
Read/Update Subscription
GET https://secure.fusebill.com/v1/subscriptions
PUT https://secure.fusebill.com/v1/subscriptions
Sample GET Request
curl -X POST "https://secure.fusebill.com/v1/subscriptions" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere" \
-d "{customerid:YourCustomerIdHere,code:'YourPlanCodeHere',name:'YourPlanNameHere',reference:null,planFrequencyId:YourPlanFrequencyIdHere}"
//Json Payload
string jsonData = "{customerid:YourCustomerIdHere,code:'YourPlanCodeHere',name:'YourPlanNameHere',reference:null,planFrequencyId:YourPlanFrequencyIdHere}";
//Setup API key
string apiKey = "YourAPIKeyHere";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://stg-secure.fusebill.com/v1/subscriptions");
//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();
}
Sample Response
{
"customerId":172677,
"planFrequency":{
"planRevisionId":122453,
"numberOfIntervals":1,
"interval":"Monthly",
"numberOfSubscriptions":1,
"status":"Active",
"setupFees":[
{
"amount":10.0,
"currency":"USD",
"id":0,
"uri":null
}
],
"charges":[
{
"amount":2.0,
"currency":"USD",
"id":0,
"uri":null
}
],
"isProrated":false,
"prorationGranularity":null,
"planFrequencyUniqueId":114,
"remainingInterval":null,
"id":114,
"uri":null
},
"planCode":"BSC2",
"planName":"Basic",
"planDescription":"Basic Monthly Services for Kennedy Consulting",
"planReference":null,
"status":"Cancelled",
"reference":null,
"subscriptionOverride":null,
"hasPostedInvoice":true,
"createdTimestamp":"2017-01-11T18:35:37",
"activatedTimestamp":null,
"provisionedTimestamp":"2017-01-11T19:07:57",
"nextPeriodStartDate":null,
"scheduledActivationTimestamp":"2017-02-01T05:00:00",
"subscriptionProducts":[
],
"remainingInterval":null,
"remainingIntervalPushOut":null,
"openSubscriptionPeriodEndDate":null,
"chargeDiscount":null,
"setupFeeDiscount":null,
"chargeDiscounts":[
],
"setupFeeDiscounts":[
],
"customFields":null,
"planAutoApplyChanges":false,
"autoApplyCatalogChanges":false,
"monthlyRecurringRevenue":0.0000,
"netMonthlyRecurringRevenue":0.0000,
"amount":12.0000,
"contractStartTimestamp":null,
"contractEndTimestamp":null,
"expiredTimestamp":null,
"coupons":[
],
"subscriptionHasRecurringEndOfPeriodCharge":false,
"id":122453,
"uri":"https://secure.fusebill.com/v1/subscriptions/122453"
}
Sample PUT Request
curl -X PUT "https://secure.fusebill.com/v1/subscriptions" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere" \
-d "{id:YourSubscriptionIdHere,customerId:YourCustomerIdHere,planCode:'PlanCode',planName:'PlanName',status:'Draft',reference:null,subscriptionProducts:[]}"
//Json Payload
string jsonData = "{id:YourSubscriptionIdHere,customerId:YourCustomerIdHere,planCode:'PlanCode',planName:'PlanName',status:'Draft',reference:null,subscriptionProducts:[]}";
//Setup API key
string apiKey = "YourApiKeyHere";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://stg-secure.fusebill.com/v1/subscriptions");
//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();
}
Sample Response
{
"firstName":"John",
"middleName":null,
"lastName":"Smith",
"companyName":"Acme Inc.",
"suffix":null,
"primaryEmail":null,
"primaryPhone":null,
"secondaryEmail":null,
"secondaryPhone":null,
"title":"Mr",
"reference":null,
"status":"Draft",
"customerAccountStatus":"Good",
"currency":"USD",
"customerReference":{
"reference1":null,
"reference2":null,
"reference3":null,
"salesTrackingCodes":[
],
"id":169456,
"uri":"https://secure.fusebill.com/v1/customers/169456"
},
"customerAcquisition":{
"adContent":null,
"campaign":null,
"keyword":null,
"landingPage":null,
"medium":null,
"source":null,
"id":169456,
"uri":"https://secure.fusebill.com/v1/customers/169456"
},
"monthlyRecurringRevenue":0.0,
"netMonthlyRecurringRevenue":0.0,
"salesforceId":null,
"salesforceAccountType":null,
"salesforceSynchStatus":"Enabled",
"netsuiteId":null,
"netsuiteCustomerType":"",
"portalUserName":null,
"parentId":null,
"id":169456,
"uri":"https://secure.fusebill.com/v1/customers/169456"
}
Step 4 - Show a Checkout Confirmation Page
After configurations are performed it is common to provide a checkout page that will show the new subscriber a sample of the first invoice. This way they can confirm their buying decision by providing a payment method.
This can be achieved by calling POST CustomerActivation?Preview=true
This call will simulate what will happen when the customer is activated without actually committing the signup. When the “Preview=true” parameter is set, the Fusebill API will return a sample response of the invoice that will be generated.
This sample response can be consumed by the registration page and used to render a Checkout validation. Note that the sample response will consider Discounts and Taxation and provide a Final total amount. The Final total amount should be temporarily saved as it will be needed in Step 6.
Checkout Confirmation
POST https://secure.fusebill.com/v1/CustomerActivation?preview=true
Sample Request
curl -X POST "https://secure.fusebill.com/v1/CustomerActivation?preview=true" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere" \
-d "{customerId:YourCustomerIdHere,activateAllsubscriptions:true}"
//Query string
string previewQuery = "false";
//Json Payload
string jsonData = "{'customerID':169493,'activateAllSubscriptions':false}";
//Setup API key
string apiKey = "Your Api Key Here";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://stg-secure.fusebill.com/v1/CustomerActivation?preview="+previewQuery);
//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();
}
Sample Response
{
"firstName": "John",
"middleName": "B",
"lastName": "Smith",
"companyName": "Acme Inc",
"suffix": "Sr",
"primaryEmail": "[email protected]",
"primaryPhone": "809997777",
"secondaryEmail": "[email protected]",
"secondaryPhone": "1 (800) 445-6000",
"title": "Mr",
"reference": null,
"status": "Active",
"customerAccountStatus": "Good",
"currency": "USD",
"customerReference": {
"reference1": null,
"reference2": null,
"reference3": null,
"salesTrackingCodes": [],
"id": 169494,
"uri": "https://secure.fusebill.com/v1/CustomerActivation/169494"
},
"customerAcquisition": {
"adContent": null,
"campaign": null,
"keyword": null,
"landingPage": null,
"medium": null,
"source": null,
"id": 169494,
"uri": "https://secure.fusebill.com/v1/CustomerActivation/169494"
},
"monthlyRecurringRevenue": 0,
"netMonthlyRecurringRevenue": 0,
"salesforceId": null,
"salesforceAccountType": null,
"salesforceSynchStatus": "Enabled",
"netsuiteId": null,
"netsuiteCustomerType": "",
"portalUserName": null,
"parentId": null,
"id": 169494,
"uri": "https://secure.fusebill.com/v1/CustomerActivation/169494"
}
Step 5 - Add and Validate a Payment Method
Now that the new subscriber has a checkout page showing the initial charge that will be taken, you can capture their desired Payment Method. When submitting a Payment method, the Fusebill system will first attempt to Validate the Payment method with your Gateway Provider. If the validation attempt fails, a generic error should be returned to the subscriber and a limited number of attempts should be allowed to submit a valid payment method.
Use Ajax Transparent Redirect Page
Add and Validate Payment Method (Credit Card)
POST https://secure.fusebill.com/v1/paymentmethods/creditcard
Transparent Redirect
Fusebill also offers an alternative service where you can create a transparent redirect page to capture customer payment method information and avoid being subject to PCI compliance. Read more on transparent redirect here.
Sample Request
curl -X POST "https://secure.fusebill.com/v1/paymentMethods/creditCard" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere" \
-d "{customerId:YourCustomerIdHere,cardNumber:4111111111111111,firstName:'John',lastName:'Doe',expirationMonth:01,expirationYear:20,cvv:123,address1:'232 Herzberg Road',address2:'Suite 203',countryId:124,stateId:9,city:'Kanata',postalZip:'K2K 2A1',isDefault:true}"
Sample Response
{
"maskedCardNumber":"************1111",
"cardType":"Visa",
"expirationMonth":1,
"expirationYear":20,
"customerId":172677,
"firstName":"John",
"lastName":"Doe",
"address1":"232 Herzberg Road",
"address2":"Suite 203",
"countryId":124,
"country":"CAN",
"stateId":9,
"state":"Ontario",
"city":"Kanata",
"postalZip":"K2K 2A1",
"isDefault":false,
"externalCustomerId":null,
"externalCardId":null,
"storedInFusebillVault":true,
"id":82620,
"uri":null
}
Step 6 - Attempt a Collection for Total Amount
Once a payment method is validated on a customer, a payment for the first invoice final total amount should be made against the payment method. Failure should provide the user with a generic error message and the submitted payment method should be cleared out. Success will result in the customer having an amount of money on deposit that will exactly cover the first invoice.
Payment Collection
Sample Request
Sample Response
{
"maskedCardNumber":"************1111",
"cardType":"Visa",
"expirationMonth":1,
"expirationYear":20,
"customerId":172677,
"firstName":"John",
"lastName":"Doe",
"address1":"232 Herzberg Road",
"address2":"Suite 203",
"countryId":124,
"country":"CAN",
"stateId":9,
"state":"Ontario",
"city":"Kanata",
"postalZip":"K2K 2A1",
"isDefault":false,
"externalCustomerId":null,
"externalCardId":null,
"storedInFusebillVault":true,
"id":82620,
"uri":null
}
Step 7 - Finalize
Once a customer has correct contact data, properly configured subscriptions, a validated payment method and an initial payment processed for the first projected invoice, it is time to Finalize the new sign up. This is achieved by calling POST CustomerActivation.
When called, both the customer and subscription statuses will be set to “Active” and the first invoice will be posted. The Fusebill system will automatically allocate the available funds on the customer to the first invoice.
The customer should be redirected to a success confirmation screen or continued through for further configurations required by your system for final provisioning.
Activate Customer
Sample Request
curl -X POST "https://secure.fusebill.com/v1/CustomerActivation?preview=true" \
-H "Content-Type: application/json" \
-H "Authorization: Basic YourAPIKeyHere" \
-d "{customerId:YourCustomerIdHere,activateAllsubscriptions:true}"
//Query string
string previewQuery = "false";
//Json Payload
string jsonData = "{'customerID':169493,'activateAllSubscriptions':false}";
//Setup API key
string apiKey = "Your Api Key Here";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://stg-secure.fusebill.com/v1/CustomerActivation?preview="+previewQuery);
//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();
}
Sample Response
{
"firstName": "John",
"middleName": "B",
"lastName": "Smith",
"companyName": "Acme Inc",
"suffix": "Sr",
"primaryEmail": "[email protected]",
"primaryPhone": "809997777",
"secondaryEmail": "[email protected]",
"secondaryPhone": "1 (800) 445-6000",
"title": "Mr",
"reference": null,
"status": "Active",
"customerAccountStatus": "Good",
"currency": "USD",
"customerReference": {
"reference1": null,
"reference2": null,
"reference3": null,
"salesTrackingCodes": [],
"id": 169494,
"uri": "https://secure.fusebill.com/v1/CustomerActivation/169494"
},
"customerAcquisition": {
"adContent": null,
"campaign": null,
"keyword": null,
"landingPage": null,
"medium": null,
"source": null,
"id": 169494,
"uri": "https://secure.fusebill.com/v1/CustomerActivation/169494"
},
"monthlyRecurringRevenue": 0,
"netMonthlyRecurringRevenue": 0,
"salesforceId": null,
"salesforceAccountType": null,
"salesforceSynchStatus": "Enabled",
"netsuiteId": null,
"netsuiteCustomerType": "",
"portalUserName": null,
"parentId": null,
"id": 169494,
"uri": "https://secure.fusebill.com/v1/CustomerActivation/169494"
}
Updated over 4 years ago
Congrats, you have now completed a checkout page.