post https://secure.fusebill.com/v1/Refunds
This function allows you to create a refund on a specific customer for a specific amount applied to a specific payment. Note that if the payment has been fully allocated to invoices then you must include a RefundAllocation to indicate which invoice to take payment value from and that the total of all the RefundAllocations must match the total of the refund amount.
Request Parameters
Property | Type | Description | Required |
---|---|---|---|
reference | String | This is the text reference attached to the refund [Max Length: 500 characters] | Optional |
originalPaymentId | Integer | This is the Fusebill Payment ID of the payment the refund will apply against. | Yes |
amount | Decimal | This is the amount of the refund. | Yes |
refundAllocations | List of objects. Defined below. | This is an optional list of invoice allocations which tells Fusebill how to split the value of this refund over multiple invoices. | Optional |
method | Enum:{PaymentMethod, Check, Cash, DirectDeposit} | This dictates how the refund is/will be processed. Defaults to PaymentMethod, which means Fusebill will refund directly to the customer's payment method via the corresponding payment gateway. | Optional |
RefundAllocations Resource Properties
Property | Type | Description |
---|---|---|
invoiceId | Integer | This is the Invoice ID for the Invoice this refund allocation applies against. |
amount | Decimal | This is the dollar amount to apply against this invoice. |
Examples
curl -X POST "https://secure.fusebill.com/v1/refunds/" \
-H "Content-Type: application/json" \
-H "Authorization: Basic {APIKey}" \
-d "{originalPaymentId:{paymentId},reference:'this is a test refund',amount:10}"
//Json Payload
string jsonData = "{originalPaymentId:{paymentId},reference:'this is a test refund',amount:10}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/refunds/");
//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 = {"originalPaymentId":{id},"reference":'this is a test refund','amount':10}
#Pass in your URI, Payload and Headers
r = requests.post('https://secure.fusebill.com/v1/refunds', data=json.dumps(payload), headers=headers)
print(r.content)
{
"reference": "refund",
"originalPaymentId": 66889199,
"amount": 50.0,
"refundAllocations": [
{
"invoiceId": 1234567,
"amount": 10.0
},
{
"invoiceId": 1234566,
"amount": 40..
}
]
}
Response
{
"paymentActivityId":17505,
"reference":null,
"effectiveTimestamp":"2014-09-18T04:00:00",
"description":"Refund of payment 675658 ",
"customerId":45892,
"originalPaymentActivityId":17502,
"amount":10.0000,
"currency":"USD",
"invoiceAllocations":[
{
"invoiceId":51993,
"invoiceNumber":1618,
"amount":10.0000,
"outstandingBalance":10.0000,
"uri":"https://secure.fusebill.com/v1/Refunds/51993"
}
],
"unallocatedAmount":0.0,
"id":675695,
"uri":"https://secure.fusebill.com/v1/Refunds/675695"
}
{
"ErrorId": 0,
"HttpStatusCode": 400,
"Errors": [
{
"Key": "Api Error",
"Value": "The refund for 50.0 exceeds the unallocated payment amount of 5.000000. Please assign the remaining 45.000000 to an invoice(s)"
}
]
}