Connecting to NetRegistry's External Gateway for eCommerce transactions

Description from: http://www.chilisoft.com/caspdoc/

Using NetRegistry's e-payment gateway with ASP.

IMPORTANT: The following information is only relevant to clients hosted on our Chilisoft ASP servers.

E-commerce on the ASP server is enabled by including ecom.asp in your ASP script. ecom.asp will be located in the /secure directory off your website base - if it is not, please contact NetRegistry Technical Support.

The /secure directory is linked to our https server so you can collect sensitive information securely. Any documents and subdirectories under /secure will be available under the following URL :

https://secure.netregistry.net/your_domain.com.au/

For example, if your domain was www.shopping.com and your script to collect and process credit cards was called "checkout.asp", you would place "checkout.asp" in www.shopping.com/secure/ and redirect clients to the following URL :

https://secure.netregistry.net/shopping.com/checkout.asp

ecom.asp provides the following API :

ecom_process

(MERCHID,PASSWORD,AMOUNT,CCNUM,CCEXP,COMMENT)

returns : 1 on success,  0 on failure

 (Please note : this return code does NOT indicate if the card was successfully  processed - it provides very basic sanity checking of the input data, and success here only indicates the request was passed on to the payment gateway.)

All arguments to ecom_process are strings, and all fields must be supplied and non-empty.

MERCHID = Your merchant ID as provided by NetRegistry. Should be a 2 or 3 digit number.
(e.g. "12")

PASSWORD = Your external access password.

AMOUNT = The amount you wish to charge, including the cents.
(e.g. "15.44" = $15.44 )

CCNUM = The credit card number, without spaces or separators.
(e.g. "4564123412341234" )

CCEXP = credit card expiry date, in the form mm/yy.
(e.g. "12/03" for December 2003)

COMMENT = A comment for the transaction, for later tracking.
(e.g. "Order #111")

               

If ecom_process returns 0, the reason for the rejection will be in the ecom_problem variable. (see example script below). You must check if ecom_process succeeds before calling any of the functions below, or your script may return an error.

Upon successful completion of the ecom_process call, the following functions can be used.

ecom_status

returns string ("approved","declined" or "failed")

This function returns the status of the transaction.

  • "approved" indicates the transaction was successful.
  • "declined" indicates the transaction was declined at the bank for some reason. (See the ecom_response_text command below).
  • "failed" indicates there was a problem with the NetRegistry - Bank gateway, or an incorrect Merchant ID / password combination was entered. It could indicate the gateway is down, or that the transaction communication was dropped. This is a rare occurrence. The majority of "failed" responses are caused by incorrect passwords or Merchant ID's. If you continually receive "failed" status, please double-check your password - if there is still a problem contact NetRegistry Technical Support.
  • ecom_status should be the first result checked. If the transaction was "failed", other functions may return undefined results.

    ecom_txnref

    returns string

    This function returns the bank transaction reference. This number should be recorded for reference. May be empty if the ecom_status is "failed" or "declined".

    ecom_settlement_date

    returns string

    This function returns the date on which the transaction took place, in Sydney Australia, Eastern Standard Time (EST).

    ecom_response_text

    returns string

    This function returns the text response from the bank. If the transaction was "declined", this function will provide more details. (e.g. "Invalid card", "Insufficient funds".)

    Some banks will return "SIGNATURE REQUIRED" in this field for a successful transaction - this is NOT an error - the transaction has gone through successfully.

    ecom_card_desc

    returns string

    This function returns the type of card that was processed. (eg "visa", "mastercard"). May be undefined if ecom_status was "declined" or "failed".

    ecom_dump

    returns string

    This function returns the full response from the bank. This should only be used for debugging purposes, as the results are not formatted or parsed, and field order may change.

    **The following functions are for Quest (National Australia Bank) customers only.

    ecom_amount

    returns string

    This function returns the amount that was processed. The value is in cents  (eg $125.23 = "12523").

    ecom_card_number

    ecom_card_expiry

    returns string

    These functions return the card number and expiry date respectively.

    ecom_rrn

    returns string

    Returns the banks rrn number for the transaction.

    Sample Scripts

    The following sample scripts are provided as an example of how to use ecom.asp. It assumes that your form has collected and checked the required information. Please note that it is vitally important to do safety and sanity checking of any input to your script.

    There are two examples, for VBScript and JavaScript ASP.

    If your ASP script is not located in the /secure directory, you will need to adjust the #include line appropriately.

    Example 1: VBScript

    <!-- #include file="ecom.asp" -->
    <%

    'To store the result from ecom_process
    Dim process_result

    MERCHID = "44"
    PASSWORD = "mypassword"

    'The following are hard-coded for example only.
    AMOUNT = "43.65"
    CCNUM = "4111111111111111"
    CCEXP = "03/01"
    COMMENT = "Order #2323"

    'Process the transaction
    process_result=ecom_process(MERCHID,PASSWORD,AMOUNT,
    CCNUM,CCEXP,COMMENT)

    'Check the result from the process call.
    if process_result = 0 then
         

      'Process call failed - check ecom_problem for the problem.
      Response.write "The following error occurred, (credit card was not processed)
      <BR><BR>"
      Response.write ecom_problem
      else

      'Process call succeeded.
      if ecom_status = "approved" then

      Response.write "The transaction was approved.<BR>"
      Response.write "The transaction reference for this order is : "

      Response.write ecom_txnref
      Response.write "<BR>The type of card processed was : "

      Response.write ecom_card_desc

      elseif ecom_status = "declined" then

      Response.write "The transaction was declined.<BR>"
      Response.write "The reason given is : "
      Response.write ecom_response_text

      elseif ecom_status = "failed" then

      Response.write "The transaction failed. This may be due to network "
      Response.write "problems. Please try again in a few minutes. If the "
      Response.write "problem persists, please contact the site owner."

      end if

    end if

    %>

    Example 2: JavaScript

    <%@ Language=JavaScript%>
    <!-- #include file="ecom.asp" -->
    <%

    MERCHID = "44";
    PASSWORD = "mypassword";

    //The following fields are hard-coded for example only.
    AMOUNT = "43.65";
    CCNUM = "4111111111111111";
    CCEXP = "03/01";
    COMMENT = "Order #2323";

    //Process the transaction
    process_result = ecom_process(MERCHID,PASSWORD,AMOUNT,CCNUM,CCEXP,COMMENT);

    //Check the result from the process call.
    if (process_result == 0) {

      //Process call failed - check ecom_problem for the problem.
      Response.write("The following error occurred, (credit card was not processed) <BR><BR>");
      Response.write(ecom_problem);
      }
      else {

      //Process call succeeded.
      if (ecom_status() == "approved") {
        Response.write("The transaction was approved.<BR>");
        Response.write("The transaction reference for this order is : ");
        Response.write(ecom_txnref());
        Response.write("<BR>The type of card processed was : ");
        Response.write(ecom_card_desc());

      }

      if (ecom_status() == "declined") {

      Response.write("The transaction was declined.<BR>");
      Response.write("The reason given is : ");
      Response.write(ecom_response_text());

      }

      if (ecom_status() == "failed") {

      Response.write("The transaction failed. This may be due to network ");
      Response.write("problems. Please try again in a few minutes. If the ");
      Response.write("problem persists, please contact the site owner.");
      }

      }

    }
    %>

    Related topics

    © 1997- 2008 Netregistry Pty Ltd