Generating HPP Links

This section explains how to use the AGMS Code Library's HPP Class to generate hosted payment page hashes and links over the HPP API.

HPP Class Quick Example

<?php
/**
 * An example of a generating a basic HPP using the AGMS PHP Library
 **/

// Include the library
require('AGMS/init.php');

// Set up the API connection
$hpp = new \AGMS\HPP();

// Configure the payment page
$params = array(
            'transaction_type' => array('value' => 'sale'),
            'amount' => array('value' => '20.00'),
            'first_name' => array('setting' => 'required'),
            'last_name' => array('setting' => 'required'),
            'zip' => array('setting' => 'required'),
            'email' => array('setting' => 'required'),
        );

// Generate the page hash with the specified configuration
$result = $hpp->generate($params);

// Print an HTML link for testing
echo 'Example HPP link';

?>
/**
 * An example of a generating a basic HPP using the AGMS Ruby Library
 **/
// Include the library
require 'agms'

// Initialise the library configuration
Agms::Configuration.init('init.yml')

// Set up the API connection
hpp = Agms::HPP.new

// Configure the payment page
params = {
    :transaction_type => { :value => 'sale'},
    :amount => { :value => '20.00'},
    :first_name => {  :setting => 'required'},
    :last_name => { :setting => 'required'},
    :zip => { :setting => 'required'},
    :email => { :setting => 'required'},
    :hpp_format => { :value => '1'}
}

// Generate the page hash with the specified configuration
result = hpp.generate(params);

// Print an HTML link for testing
puts 'Example HPP link';
/**
 * An example of a generating a basic HPP using the AGMS Python Library
 **/

// Include the library
import 'agms'

// Initialise the library configuration
agms.Configuration.init('init.init')

// Set up the API connection
hpp = agms.HPP()

// Configure the payment page
params = {
    'transaction_type': {'value': 'sale'},
    'amount': {'value': '20.00'},
    'first_name': {'setting': 'required'},
    'last_name': {'setting': 'required'},
    'zip': {'setting': 'required'},
    'email': {'setting': 'required'},
    'hpp_format': {'value': '1'},
}

// Generate the page hash with the specified configuration
result = hpp.generate(params);

// Print an HTML link for testing
print 'Example HPP link';
                        
// Testing what will happen if we use a lot of text in one single line which is most common in programming code
#ucase("Coldfusion example here")#

HPP Class: Constructor

// AGMS HPP Class Constructor
public array \AGMS\HPP::__construct ( [ string $username [, $password [, $accountnumber [, $apikey ] ] ] ] )
// AGMS HPP Class Constructor
HPP::initialise ( [ string username [, password [, accountnumber [, apikey ] ] ] ] )
// AGMS HPP Class Constructor
HPP.__init__( self, [ string username [, password [, accountnumber [, apikey, [client] ] ] ] ] )

The HPP Class can be instantiated with no parameters, or gateway credentials can be explicitly set for a transaction. If no credentials are provided, the default credentials configured in init.php will be used.

HPP Class: generate Method

// AGMS HPP Class generate() method
public array \AGMS\HPP::generate ( array $parameters )
// AGMS HPP Class generate() method
HPP::generate ( Hash parameters )
// AGMS HPP Class generate() method
Transaction.generate ( dict parameters )                        

The AGMS HPP object's "generate" method executes an API request to generate an HPP hash according to the configuration parameters provided.

A full listing of the Request parameters is available in the Requests tab, and a full listing of Response parameters is available in the Responses tab.

The parameter array is a two dimensional array, with each field containing an array of its configuration values. A field can be configured with a "value", "setting", or both.

HPP Class: getLink Method

// AGMS HPP Class getLink() method
public string \AGMS\HPP::getLink ( )
// AGMS HPP Class getLink() method
HPP::getLink ( Hash parameters )
// AGMS HPPn Class get_link() method
Transaction.get_link ( dict parameters )

The AGMS HPP object's "getLink" method returns a full URL that can be used to link to the payment page using the generated hash.

Request Fields

The following fields can be passed into the AGMS HPP Class to generate an HPP hash.

Basic Configuration Parameters

Parameter Value Description
transaction_type sale
auth
safe only
Type of transaction to be processed.
enable_donation Boolean If enabled, the form allows the customer to enter in their own custom dollar amount. This behavior is intended for use to collect donations for amounts at the discretion of the supporter. If an amount is provided with enable_donation set as TRUE, that will be the default amount which can be edited by the supporter.
processing_account_id Integer If multiple processing accounts are configured in the same gateway account, use this field to specify which account to use. If gateway is configured for only one processing account, this field is not required.
amount Decimal Amount to be processed, required unless this is a donation form or safe only, in which case it can be blank.
order_description String Order description, appears by default on gateway-generated receipts and shows on the payment page as what the customer is paying for. Recommended for all sales and auths.
order_id String Can be used to tie transactions back to a record/transaction ID in your system.
tax_amount Decimal The amount of the transaction that was sales tax. The tax_amount is not added in to the total amount charged to the cardholder, this field is informational only and is also used for Level 2 and Level 3 processing qualifications.
shipping_amount Decimal The amount of the transaction that was shipping. The shipping_amount is not added in to the total amount charged to the cardholder, this field is informational only.
po_number String Can be used to track Customer PO numbers with the transaction, also used for Level 2 and Level 3 credit card processing qualifications.
return_url String The URL to return the user to after the payment is complete. Must be a fully qualified URL terminating at a specific page. The response will be returned to this URL with fields defined in the Responses tab. If no return_url is specified, a generic thank you page will be used. It is recommended that the URL provided is an https URL, otherwise the user's browser may trigger an unsecure content warning.
enable_auto_add_to_safe Boolean If enabled, all customers will automatically be added to the Customer SAFE (tokenized).
max_link_uses Integer The maximum number of times this form can be successfully used before it is disabled. If the hash is being generated for a specific transaction, a value of 1 should be used to ensure that the customer only pays once. If no value is provided, the form can be used an unlimited number of times.
start_date YYYY-MM-DD The date to automatically enable the form.
start_time HH:MM:SS or HH:MM The time of day to automatically enable the form, in 24h format. Times are in local timezone as configured by administrator in the gateway settings.
end_date YYYY-MM-DD The date to automatically disable the form.
end_time HH:MM:SS or HH:MM The time of day to automatically disable the form, in 24h format. Times are in local timezone as configured by administrator in the gateway settings.
safe_id Integer If specified with a valid SAFE Record ID, user will not have to enter payment information into the form. The payment information on file will be used.
suppress_safe_option Boolean If true, HPP Format 1 will not show a checkbox allowing the customer to save their information in the Customer SAFE. By default, template 1 will show this checkbox.

Customer Billing Parameters

Customer's information as it appears on their method of payment.

Fields with the "Setting" column checked can accept a "setting" parameter in addition to a "value" parameter. The setting parameter accepts a value of "visible", "disabled", "required", or "hidden".

  • Visible fields will be editable and shown to the user.
  • Disabled fields will show on the form with the value specified but will not be editable.
  • Required fields will be visible and editable and must be completed by the user.
  • Hidden fields can contain a value that will record with the transaction, but will be hidden from the user and not editable.

Values can be provided fields configured as Visible and Required to serve as a default value. If a value is provided, but no setting value is provided or

Parameter Value Setting Description
first_name String Required for all sales and auths.
last_name String Required for all sales and auths.
company_name String Recommended for all corporate sales and auths.
address String
address_2 String
city String
state String
zip String
country String
phone String
fax String
email String Automatic customer email receipts will be sent to this address, if you have them enabled.
website String

Customer Shipping Parameters

Information for the individual that the product is being shipped to or where the services are being provided. These fields are optional.

Parameter Value Setting Description
shipping_first_name String
shipping_last_name String
shipping_company_name String
shipping_address String
shipping_address_2 String
shipping_city String
shipping_state String
shipping_zip String
shipping_country String
shipping_email String
shipping_phone String
shipping_fax String
shipping_tracking_number String
shipping_carrier String

Custom Parameters

Custom fields are fields that can be used by you to store any additional parameters that you need. Custom fields can be custom labeled in the gateway settings, so instead of "Custom Field 1" it could display as "Shirt Size". The parameter names below are the default generic values, however you can also define custom field aliases, such as "shirt_size" in place of "custom_field_1" in the init.php configuration.

Parameter Value Setting Description
custom_field_1 String
custom_field_2 String
custom_field_3 String
custom_field_4 String
custom_field_5 String
custom_field_6 String
custom_field_7 String
custom_field_8 String
custom_field_9 String
custom_field_10 String

Response Fields

HPP Class Response

The following fields are returned in an array by the AGMS HPP Class after creating a hash using the generate method.

Key Value Description
hash String Unique hash which can be used with an HPP URL to load the configured hosted payment page.

Return URL Response

The following fields are posted back to your server if a return_url is provided.

Key Value Description
authcode Integer Transaction authorization code as provided by the processor.
avsmsg String Text description of the avs code.
transid Integer A unique ID generated by the gateway for this transaction. This should be stored in your system along with your local transaction record for future reconciliation with gateway records.
authmsg String Text description of the authorization response.
statuscode Integer 1 = APPROVAL
2 = DECLINE
10 = VALIDATION ERROR
20 = DATA ERROR OR SYSTEM ERROR
30 = EXCEPTION
avscode String Y, D, or M = Exact 5 character numeric zip match
A or B = Address (street number) match only
W = 9 character numeric zip match only
Z, P, or L = 5 character numeric zip match only
N or C = No address or zip match
U = Address unavailable
G or I = Non-U.S. issuer does not participate in AVS program
R = Issuer system unavailable
E = Not a mail/phone/ecommerce order
S = AVS service not supported
0, O, or B = AVS not available
cvv2code String M = CVV2/CVC2 Match
N = CVV2/CVC2 No Match
P = Not Processed
S = Merchant has indicated that CVV2/CVC2 is not present on card
U = Issuer is not certified and/or has not provided Visa encryption keys.
cvv2msg String Text description of the cvv2code.
safeid Integer If safe_action was used, a safeid is returned.
statusmsg String Text description of the statuscode.

Frequently Asked Questions