post https://secure.fusebill.com/v1/payments
This function allows you to create a new payment on a specific customer for a specific amount using a specific payment method.
Request Parameters
Property | Type | Description | Required |
---|---|---|---|
customerId | Integer | This is the Id of the Customer to whom this Payment is being applied to. | Yes |
reference | String | This is the reference field you can use to identify this payment. [Max Length: 500 characters] | Optional |
amount | Decimal | This is the amount of the payment | Yes |
paymentMethod | Enum:{ CreditCard, Cash, Check, DirectDeposit, ACH} | This indicates the type of payment method being used. | Yes |
paymentMethodId | Integer | This is the ID of the payment method to be used to fund this payment. | Yes if paymentMethod is "ACH" or "CrediCard" |
useDefaultPaymentMethod | Boolean | If true, the customer's default payment method will be used | Optional |
paymentAllocations | List of objects. Defined below | This is an optional list of payment allocations which tells Fusebill how to split the value of this payment over many invoices. | Optional |
source | Enum: {Manual, Automatic, SelfServicePortal, Import} | Indicates the source of the payment | Yes |
autoAllocate | Boolean | If true, then the payment will be automatically allocated to the customer's outstanding invoices in the order defined by autoAllocateOrder | Optional |
autoAllocateOrder | Enum: {OldestToNewest, NewestToOldest} | Defines how to automatically allocate the payment if autoAllocate is true | Optional |
Payment Allocations Properties
Property | Type | Description |
---|---|---|
invoiceID | Integer | This is the invoice ID for the invoice this allocation applies against. |
amount | Decimal | This 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"
}
]
}