"SetupPayment" as explained above is the simple approach to begin processing payments using the {{platform.Name_Space_2}}API. For more control over the user experience, please follow the custom payment method as described below.
Invoke the process payment method as explained below when you are ready to process the payment e.g. a button click. "ProcessPayment" is an asynchronous call - it returns immediately and invokes the "CallbackFunction" when it receives a response from the {{platform.Name_Space_2}}server.
| Property | Type | Description |
|---|---|---|
AuthKey |
string | Unique key created using "Create AuthKey" operation (Refer AuthKey). You may store this in a hidden field and then pass the value. |
{{platform.PaymentReason}} |
string | {{platform.PaymentSpaceReason}} to attach to a payment |
{{platform.Reference}}1 |
string | {{platform.Reference}} 1 for the payment. This is optional if supplied while creating the AuthKey (Refer AuthKey). |
{{platform.Reference}}2 |
string | {{platform.Reference}} 2 for the payment |
{{platform.Reference}}3 |
string | {{platform.Reference}} 3 for the payment |
{{platform.InternalNote}} |
string | {{platform.InternalSpaceNote}} for the payment |
EmailAddress |
string | Customer's email address. |
Currency |
string |
The currency that the transaction is to be processed in as an ISO 4217 code (see section Currency List) Your bank merchant account must be configured to accept the currency used in this field. Please speak to your bank if you are unsure what currencies your bank merchant account can transact in . |
Amount |
string | Amount to process if supplied while creating the AuthKey (Refer AuthKey) |
AmountOriginal |
string | Total payment amount without surcharge - this field is for information and reporting only and does not alter the value of the transaction (as specified by Amount) |
AmountSurcharge |
string | Surcharge amount for payment - this field is for information and reporting only and does not alter the value of the transaction. (as specified by Amount) |
CardNumber |
numeric | Card number you wish to charge |
{{platform.CVN}} |
numeric | Card verification number |
ExpiryMonth |
numeric | Expiry month of the card |
ExpiryYear |
numeric | Expiry year of the card |
CardHolderName |
string | Name on the card |
StoreCard |
boolean | Set this flag if you wish to create a {{platform.TokenLower}} to store the card details for future use. Alternatively you may render a checkbox on your form for your customer to opt in. |
CallbackFunction |
function | This is a callback you provide to handle the response from the {{platform.Name_Space_2}}API. Please see below for more information on this. |
Type |
string | Specifies the capture type: |
{{platform.JS_NAMESPACE}}.ProcessPayment({
AuthKey: $("#AuthKey").val(),
{{platform.PaymentReason}}: $("#{{platform.PaymentReason}}").val(),
{{platform.Reference}}1: $("#{{platform.Reference}}1").val(),
{{platform.Reference}}2: $("#{{platform.Reference}}2").val(),
{{platform.Reference}}3: $("#{{platform.Reference}}3").val(),
{{platform.InternalNote}}: $("#{{platform.InternalNote}}").val(),
EmailAddress: $("#EmailAddress").val(),
Amount: $("#Amount").val(),
AmountOriginal: $("#AmountOriginal").val(),
AmountSurcharge: $("#AmountSurcharge").val(),
Currency: $("#Currency").val(),
CardNumber: $("#CardNumber").val(),
{{platform.CVN}}: $("#{{platform.CVN}}").val(),
ExpiryMonth: $("#ExpMonth").val(),
ExpiryYear: $("#ExpYear").val(),
CardHolderName: $("#CardHolderName").val(),
StoreCard: $("#StoreCard").prop("checked"),
CallbackFunction: ProcessPaymentCallBack,
Type: $("#Type").val()
});
The "CallbackFunction" is a JavaScript function you provide to handle the response from the {{platform.Name_Space_2}}API. It does the following:
function ProcessPaymentCallBack(result) {
var errors = new Array();
if (result.AjaxResponseType == 0) {
//AJAX call was successful
if (result.ApiResponseCode == 0) {
//API returned success.
//Refer to (API Response Codes) for API Response codes.
//Submit result.ResultKey to your server for further
//processing (Refer Transaction Result)
}
else if (result.ApiResponseCode == 300) {
if (result.RedirectionUrl != null && result.RedirectionUrl.length > 0)
window.location.href = result.RedirectionUrl;
else
errors = result.Errors;
}
else {
errors = result.Errors;
}
}
else if(result.AjaxResponseType == 1) {
//Error with AJAX call
errors = result.Errors;
}
else if(result.AjaxResponseType == 2) {
//AJAX call timed out
errors = result.Errors;
}
//Show errors on the page
if (errors.length > 0) {
var ul = $("<ul></ul>");
$.each(errors, function (i, r) {
ul.append("<li>" + r.Message + "</li>");
});
$(".validation-summary").append(ul).show();
}
}
Result Object
The result object is described as below.
| Property | Type | Description |
|---|---|---|
AjaxResponseType |
numeric | This is the result of the AJAX call. This will assist you in handling the call back. |
ApiResponseCode |
numeric | This is the response code returned by the {{platform.Name_Space_2}}API |
Errors |
List of errors returned. | |
ResultKey |
string | This is the result key that you will have to submit to retrieve the transaction result and present the receipt to the customer,"Retrieve Transaction Result" (Refer Transaction Result). |
RedirectionUrl |
string | URL to use for redirection (if you receive an ApiResponseCode of 300, perform a full browser redirect with this value). |