Skip to content
brendo edited this page Jun 12, 2012 · 6 revisions

API Reference

processPayment(array $values = array()):array

@param array $values An associative array of field data, usually from $_POST. Note that transactions have required fields, described by HostedPaymentsCVNSettings::getRequiredFields().

@return array An associative array that at minimum contains status, response-code and response-message keys.

Given an associative array of data, $values, this function will merge with the default eWay fields and send the transaction to eWay's Merchant Hosted Payments CVN gateway. This function will return an associative array detailing the success or failure of a transaction and any supporting information. For more information, check the eWay Reference

How to use

Using the example of a user sending a Donation, the following code will send a payment to the eWay API. The form data should be sending the values

protected function __trigger(){
	if(isset($_REQUEST['redirect'])) {
		$redirect = $_REQUEST['redirect'];
		unset($_REQUEST['redirect']);
	}

	include(TOOLKIT . '/events/event.section.php');

	// Include eWay
	require_once EXTENSIONS . '/eway/lib/class.api.php';
	$reply = eWayAPI::processPayment($_POST);

	// Have a look at reply and determine if it was successful or not
	// The developer can edit the Event XML or redirect

	return $result;
}

Example Responses

The following are the value of $reply in the above example

Successful Transaction

array(5) {
	["status"]=> string(8) "Approved"
	["response-code"]=> string(2) "00"
	["response-message"]=> string(38) "Transaction Approved(Test CVN Gateway)"
	["pgi-transaction-id"]=> string(5) "10324"
	["bank-authorisation-id"]=> string(6) "123456"
}

Data error

array(4) {
	["status"]=> string(10) "Data error"
	["response-code"]=> int(200)
	["response-message"]=> string(23) "Missing Fields: ewayCVN"
	["missing-fields"]=> array(1) {
		[0]=> string(7) "ewayCVN"
	}
}

Gateway error

array(3) {
	["status"]=> string(13) "Gateway error"
	["response-code"]=> int(100)
	["response-message"]=> string(37) "There was an error connecting to eWay"
}

eWay error

array(5) {
	["status"]=> string(8) "Declined"
	["response-code"]=> string(2) "01"
	["response-message"]=> string(33) "Refer to Issuer(Test CVN Gateway)"
	["pgi-transaction-id"]=> string(5) "10318"
	["bank-authorisation-id"]=> string(6) "123456"
}