Handling the response | Transaction Callback

The main development effort for POS partners using Tyro iClient is implementing the set of transaction callbacks. The integrated surcharge feature involves the use of the transactionCompleteCallback . The transactionCallbacks object provides this callback function, which contains the surcharge amount applied to the transaction. The specification of the relevant field is given below:

Transaction Complete Callback

Function Description Usage Required
transactionCompleteCallback Invoked when the transaction has been completed on the terminal. Called with a surcharge amount string field as part of the transactionData object as shown below table. Required
Field Type Description Usage Required
surchargeAmount String The applied surcharge amount for the given transaction. Required

Steps to follow

The steps to follow in handling the response for the integrated surcharge feature are given below:

  • The applied surcharge amount is returned to the POS in the transaction response. The transactionCompleteCallback contains the applied surcharge amount in the surchargeAmount field as shown in the example to the right.
  • The POS must obtain the returned surcharge amount and:
    • Display it clearly on the POS sales receipt accurately labelled as 'Surcharge'.
    • The POS must also store the surcharge-inclusive amount for the transaction on the sales invoice so that when refunded, the surcharge amount is automatically added back on without any manual intervention.

Example responses of the transactionCompleteCallback as well as an example implementation of the transactionCompleteCallback function are given below.

Callback function

Copy
Copied
var transactionCompleteCallbackImpl = function(response) {
  console.log("Response = " + JSON.stringify(response));

  if (response.customerReceipt) {

    console.log("Customer Receipt = " + JSON.stringify(response.customerReceipt));

    //Compiling the integrated receipt:
    if (transactionType == "purchase" && response.result == "APPROVED") {
      var surcharge = parseFloat(response.surchargeAmount);
      total = ($("#amount").val() / 100) + surcharge;
      totalamount = total;
      console.log(totalamount);
      var posReceipt = formatReceipt("\tTAX INVOICE       \r\n\r\n      Merchant 1655650     \r\n      Address line 1       \r\n      Address line 2       \r\n\r\n\tAWESOME POS   \r\n\t\r\nItems\t\t\t$\r\nCoffee\t\t\t" + "$" + ($("#amount").val() / 100) + "\r\n\t\r\nSub-total\t\t" + "$" + ($("#amount").val() / 100) + "\r\n\r\nSurcharge\t\t" + "$" + surcharge + "\r\n\r\nTotal\t\t\t" + "$" + (total) + "\r\n\r\nGST inc\t\t\t$1.00\r\n\r\nPOS ID: 2\r\nRef: 12345abc\r\n04 Jan 2019 at 02:12 PM\r\n\n\n\t--------------------\n\n" + response.customerReceipt);

      console.log(posReceipt);

      $("#customerReceipt").html(posReceipt);

    } else if (transactionType == "refund" && response.result == "APPROVED") {
      console.log(transactionType);
      var posReceipt = formatReceipt("\tTAX INVOICE       \r\n\r\n      Merchant 1655650     \r\n      Address line 1       \r\n      Address line 2       \r\n\r\n\tAWESOME POS   \r\n\t\r\nREFUND\t\t\t$\r\nAmount\t\t\t" + "$" + ($("#amount").val() / 100) + "\r\n\t\r\nSub-total\t\t" + "$" + ($("#amount").val() / 100) + "\r\n\r\nTotal\t\t\t" + "$" + ($("#amount").val() / 100) + "\r\n\r\nGST inc\t\t\t$1.00\r\n\r\nPOS ID: 2\r\nRef: 12345abc\r\n04 Jan 2019 at 02:12 PM\r\n\n\n\t--------------------\n\n" + response.customerReceipt);


      console.log(posReceipt);

      $("#customerReceipt").html(posReceipt);
    } else {
      console.log(transactionType);
      var posReceipt = formatReceipt("\t AWESOME POS      \r\n\r\n      Merchant 1655650     \r\n      Address line 1       \r\n      Address line 2       \r\n\r\n\tAWESOME POS   \r\n\t\r\nTRANSACTION FAILED\t\t\r\nResult:\t\t\t" + response.result + "\r\n\r\nPOS ID: 2\r\nRef: 12345abc\r\n04 Jan 2019 at 02:12 PM\r\n\n\n\t--------------------\n\n" + response.customerReceipt);

      console.log(posReceipt);

      $("#customerReceipt").html(posReceipt);

    }


  }
  $("#result").html(formatResult(response));
};

Example Response

Given below is an example response for the transaction showing the surcharge applied being returned in the surcharge-amount field.

Copy
Copied
{
"result":"APPROVED"
"transactionId":"3783ea1cacae254808490fcf60bbd4eb221e"
"cardType":"MasterCard"
"transactionReference":"602145"
"authorisationCode":"031054"
"issuerActionCode":"00"
"elidedPan":"xxxxxxxxxxxx5100"
"rrn":"602145141255"
"tipAmount":"1000"
"surchargeAmount":"1.00"
"baseAmount":"101.00"
"transactionAmount":"101.00"
"customerReceipt":
	"      CUSTOMER COPY       \n
	\n
	      Merchant 1655650     \n
	      Address line 1       \n
	      Address line 2       \n
	\n
	    Tyro Payments EFTPOS   \n
	\n
	MasterCard\n
	Card:    xxxxxxxxxxxx5100(s)\n
	\n
	Purchase     AUD     $100.00\n
	Surcharge    AUD       $1.00\n
                  ----------\n
	Total        AUD     $101.00\n
	\n
	APPROVED                  00\n
	\n
	Terminal ID: 8\n
	Transaction Ref: 602145\n
	Authorisation No: 031054\n
	04 Jan 2019 at 02:12 PM\n"
}
Copyright © Tyro Payments 2019-2022. All right reserved.