Send the Transaction Request

There are many components to making sure the transaction request body is sent securely to the Payment Gateway. This section goes through the essential concepts and functions you may need to use in your integration.

This page includes sample code snippets. Choose an interface and language, then click Update Code Snippets.

Authentication Data , Change Download

The CommWeb payment gatewayDirectAPI requires every transaction request to be authenticated successfully. The below snippet covers how to provide authentication data (Merchant ID and/or API Password) with each transaction.

This code snippet shows how to set credentials in the program.

    
         Select Protocol and Language to view Code Snippet.
    

From: Sample Code Download  

HTTP Headers , Change Download

HTTP Headers provide metadata information about the transaction request being sent to the the CommWeb payment gateway. This snippet demonstrates the mandatory HTTP Headers that must be set for every transaction request (the headers listed here must be set in addition to any authentication headers mentioned under Authentication Data, where applicable).

The Content-Length and Content-Type headers are critical because they tell the web server how many bytes of data to expect, and what kind, identified by a MIME type. The character encoding of your request must include only ISO-8859-1 or UTF-8 formats. See Ensure Character Encoding.

This code snippet shows how to set HTTP headers in the program.

    
         Select Protocol and Language to view Code Snippet.
    

From: Sample Code Download  

HTTP Method (POST vs PUT vs GET) , Change Download

Depending on your protocol and integration options chosen, you may need to use a specific HTTP method for each transaction. All the basic operations performed through the CommWeb payment gatewayDirectAPI use HTTP method PUT with the REST protocol (except Retrieve and CheckGateway operations); and HTTP method POST with the NVP protocol.

With REST, the HTTP method PUT updates the addressed member of the collection; or if it doesn't exist, creates a new member. For example, if the Request-URI is http://example.com/version/v1/merchant/m1/order/o1/transaction/t1, where t1 is a member of the collection resource o1, then if t1 exists the request modifies the resource t1 else creates a new member t1. The HTTP method GET retrieves a representation of the addressed member of the collection. For example, if the Request-URI is http://example.com/version/v1/merchant/m1/order/o1/transaction/t1, then GET retrieves t1.

With NVP, the HTTP method POST is utilized for all transaction operations.

This code snippet shows how to use HTTP method POST.

    
         Select Protocol and Language to view Code Snippet.
    

From: Sample Code Download  

This code snippet shows how to use HTTP method PUT.

    
         Select Protocol and Language to view Code Snippet.
    

From: Sample Code Download  

Destination URL for a Transaction Request , Change Download

The URL used to send your transaction request can change for every transaction request:

  • With NVP, you will always use the same URL for all transaction operations. In the below snippet, the function calculates the URL from configuration and appends the version of the API being used.
  • With REST, the URL will vary for every transaction operation. In the below snippet, the function calculates the URL from config, sets the version and Merchant resource values and then appends a custom list of resources and their identifiers. These custom components could represent the order and transaction resources. For more information about the format of the URL required for every operation, see the API Reference documentation.

This code snippet shows how to configure the URL for the Transaction Request.

    
         Select Protocol and Language to view Code Snippet.
    

From: Sample Code Download  

Set the URL to Send Transaction , Change Download

The code snippet shows how to set the URL to send a transaction.

    
         Select Protocol and Language to view Code Snippet.
    

From: Sample Code Download  

Verify the CommWeb payment gateway's SSL Certificate , Change Download

In order to prevent malicious attacks as well as other potential security issues, it is critical that you validate the SSL certificate of the CommWeb payment gateway when you send the transaction request. The below snippets are critical to ensure the secure transmission of your transaction request.

This code snippet shows how to verify the SSL certificate.

    
         Select Protocol and Language to view Code Snippet.
    

From: Sample Code Download  

Configure a Proxy Server , Change Download

In some network environments, it may be necessary to send the transaction request via a proxy server. This is optional and you should consult your network administrator or web hosting provider for information on whether this is relevant to your integration.

This code snippet shows how to set proxy and its authentication.

    
         Select Protocol and Language to view Code Snippet.
    

From: Sample Code Download  

Send Transaction to the CommWeb payment gateway , Change Download

As a last step, you must send your correctly formatted transaction request to the CommWeb payment gateway and wait for a response.

This code snippet shows how to send transaction to the CommWeb payment gateway.

    
         Select Protocol and Language to view Code Snippet.
    

From: Sample Code Download  

Copyright © 2023 Commonwealth Bank of Australia