/sale/createPayment.php

This method is used to create/register received payments toward a given invoice.
You can use the getOutstandingInvoicesByCustomer() to get a list of invoices that are currently open to register payments towards.

Parameters

int invoiceNumber
The invoice number of the invoice that you want the payment to be registered towards - the invoice must have an outstanding amount of at least the size of the payment before it can be accepted.
int amount
Indicates the amount/price for the work item, the currency will automatically be the currency connected to the client.
Be alert that the amount is an integer representing the lowest nominator in the particular currency (i.e. cents for Kenyan Shillings).
If you have the amount as a decimal representation then you 'just' need to multiply it by 100.
date date
This parameter indicated the date for which the work item should be created, the date must be formated as a string in accordance with the date setting of the particular company - be alert that there are several format options for a company see: Uhasibu -> settings -> company information.
boolean finalPayment
TRUE or FALSE indicating if this is the final payment towards the selected invoice - if it is the final then the invoice will no longer be considered open/outstanding, even if a (small) amount is still remaining/outstanding.
boolean vatWithheld
TRUE or FALSE indicating if the client witheld VAT (i.e. paid it on your behalf) and gave you a certificate instead.
int companyId
The company id of the Uhasibu account required
string login
The login for the API user, logins are typically emails
string password
The password for the API user

Return values

int RESULT_AMOUNT
Contains the amount of result rows in the result set
array RESULT
Array containing the individual result rows
int RESULT : POSTING_ID
The unique id of the created payment
int STATUS_CODE
The status code of the function call, any code different from 0 is an error code
string STATUS_MESSAGE
A textual description of the status code in a few words

Potential error messages

4010: Invoice not found
Occurs if no invoice could be found with the given invoice number.
4011: Amount exceedes outstainding
Occurs if the payment amount exceeds the amount still outstanding on the invoice.
4012: Deposit account not found
Occurs if the configured deposit account could not be found, the deposit account is configured in Uhasibu -> settings -> sales-settings.
1007: Internal error
This is an unexpected error, and could indicate a bug in Uhasibu, if you see this bug occur then please report it to Uhasibu support.
1008: Amount must be larger than 0
Occurs if the amount given is not larger than 0.
1009: Invalid date
Occurs if the date given does not evaluate to a valid date.
1001: Invalid credentials
Occurs when no user is found within the given companyId using the login and password provided
1002: Missing access rights
Occurs when the user credentials provided does not have access-rights to use the required part of the system.
1003: Account expired
Occurs when the company is expired i.e. due to missing subscription payment.
1006: Requests method not supported
Occurs when the request is neither a POST nor GET HTTP request type

Examples

PHP example
$APIVersion = "20120401";

function uhasibu($method, $package) {
	global $APIVersion;
	$url = "www.uhasibu.co.ke/api/" . $APIVersion . $method;
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
	curl_setopt($curl, CURLOPT_POST, true);
	curl_setopt($curl, CURLOPT_POSTFIELDS, $package); 
	$response = curl_exec($curl);
	curl_close($curl);
	return json_decode($response, TRUE);
}

$package = 
	"companyId=**COMPANYID**" .
	"&login=" . urlencode("**USERNAME**") .
	"&password=" . urlencode("**PASSWORD**") .
	"&invoiceNumber=235" 
	"&date=" . urlencode("13/12/2011") .
	"&finalPayment=TRUE" .
	"&vatWithheld=FALSE" .
	"&amount=1000000"; // 10000 of the currencys main-unit.

$response = uhasibu("/sale/createPayment.php", $package);
if ($response["STATUS_CODE"] != 0) {
	die($response["STATUS_MESSAGE"]);
}
print "newly created payment id is " . $response["RESULT"]["POSTING_ID"];