Create Payment

This function allows you to create a new payment on a specific customer for a specific amount using a specific payment method.

Request Parameters

PropertyTypeDescriptionRequired
customerIdIntegerThis is the Id of the Customer to whom this Payment is being applied to.Yes
referenceStringThis is the reference field you can use to identify this payment. [Max Length: 500 characters]Optional
amountDecimalThis is the amount of the paymentYes
paymentMethodEnum:{ CreditCard, Cash, Check, DirectDeposit, ACH}This indicates the type of payment method being used.Yes
paymentMethodIdIntegerThis is the ID of the payment method to be used to fund this payment.Yes if paymentMethod is "ACH" or "CrediCard"
useDefaultPaymentMethodBooleanIf true, the customer's default payment method will be usedOptional
paymentAllocationsList of objects. Defined belowThis is an optional list of payment allocations which tells Fusebill how to split the value of this payment over many invoices.Optional
sourceEnum: {Manual, Automatic, SelfServicePortal, Import}Indicates the source of the paymentYes
autoAllocateBooleanIf true, then the payment will be automatically allocated to the customer's outstanding invoices in the order defined by autoAllocateOrderOptional
autoAllocateOrderEnum: {OldestToNewest, NewestToOldest}Defines how to automatically allocate the payment if autoAllocate is trueOptional

Payment Allocations Properties

PropertyTypeDescription
invoiceIDIntegerThis is the invoice ID for the invoice this allocation applies against.
amountDecimalThis the dollar amount to apply against the above invoice
Examples
curl -X POST "https://secure.fusebill.com/v1/payments/" \
	-H "Content-Type: application/json" \
	-H "Authorization: Basic {APIKey}" \
	-d "{customerId:{customerId},source:'Manual',paymentMethod:'CreditCard',reference:'this is a test payment',amount:10,paymentMethodId:{paymentMethodId}}"
//Json Payload
string jsonData =
  "{customerId:{customerId},source:'Manual',paymentMethod:'CreditCard',reference:'this is a test payment',amount:10,paymentMethodId:{paymentMethodId}}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/payments/");
//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 dictionary to the Payload parameter
payload = {"customerId":{id},"source":'Manual',"paymentMethod":'CreditCard',"reference":'this is a test payment',"amount":10,"paymentMethodId":{id}}
#Pass in your URI, Payload and Headers
r = requests.post('https://secure.fusebill.com/v1/payments', data=json.dumps(payload), headers=headers)
print(r.content)
{
  "customerId": 655080,
  "reference": "abc123",
  "amount": 50.78,
  "paymentMethod": "Cash",
  "source": "Manual"
}
{
  "customerId": 655080,
  "reference": "abc123",
  "amount": 50.78,
  "paymentMethod": "Cash",
  "source": "Manual",
  "paymentAllocations": [
    {
      "invoiceID": 566934,
      "amount": 2.0
    }
  ]
}
Response
{ 
   "paymentActivityId":118419,
   "reference":"this is a test payment",
   "effectiveTimestamp":"2017-01-25T19:11:00.0009221Z",
   "description":null,
   "customerId":172677,
   "originalPaymentActivityId":null,
   "amount":10.0,
   "currency":"USD",
   "invoiceAllocations":[ 

   ],
   "refunds":[ 

   ],
   "unallocatedAmount":10.0,
   "refundableAmount":10.0,
   "id":7613586,
   "uri":"https://secure.fusebill.com/v1/payments/7613586"
}
{
    "ErrorId": 0,
    "HttpStatusCode": 400,
    "Errors": [
        {
            "Key": "payment.PaymentMethodType",
            "Value": "Allowable values are: Check, DirectDeposit, CreditCard, Cash, ACH, Paypal"
        }
    ]
}
Language
Authorization