Initializing the GETTRX.js SDK

Below are the script tags that you need to add to your checkout page to load and initialize our SDK. These will load GETTRX.js directly from our servers. These script tags should be the last scripts to be loaded on your site.

<script>
   let gettrx = null;
   
   // This function will run as soon as the script is loaded
   function loadPaymentSdk() {
    
     //Initialize the SDK (For direct merchants ONLY)
     gettrx = new GettrxOne('pk_Add_Your_Public_Key_Here');
     
     //Initialize the SDK (For ISVs & Partners that process payments on behalf of their merchants/sub-merchants)
	   //gettrx = new GettrxOne('pk_Add_Your_Public_Key_Here', { onBehalfOf: "acm_Add_a_Merchant_Account_ID_Here" })
   }
</script>
<script src="https://js-dev.gettrx.com/sdk/js/payments/v1.0/sdk.js" onload="loadPaymentSdk()"></script>

Initializing GETTRX.js

To create an instance of the GETTRX object, which serves as the entry point to the rest of the GETTRX.js library you must call the class constructor with the word new in front of it and pass the required parameters.

Constructor

new GettrxOne(publicKey, options?)

Constructor Parameters

ParameterRequired/OptionalTypeDescription
publicKeyrequiredstringYour public key (Can be retrieved from the portal)
optionsoptionalOptions objectInitialization Options (Only required for ISVs and Partners that process payments on behalf of their merchants/sub-merchants)

Options object

ParameterRequired/OptionalTypeDescription
onBehalfOfrequiredstringThis parameter is required for Partners and ISVs Only. You must specify the Account ID (acm_***) for the merchant that you will be processing payments on behalf of.

Initialization Examples

When initializing GETTRX.js as a Merchant to run payments for your own Merchant account

var gettrx = new GettrxOne('pk_your_test_public_key);

When initializing GETTRX.js as a Partner or ISV to run payments on behalf of one of your merchant/submerchants include the onBehalfOf parameter with the account's ID.

var gettrx = new GettrxOne('pk_your_test_public_key', { onBehalfOf: "acm_your_other_account_ID" });