This section explains how to use the AGMS Code Library's Transaction Class to run transactions over the Transaction API.
<?php /** * A basic example of a sale transaction using the AGMS PHP Library **/ // Include the library require('AGMS/init.php'); // Set up the API connection $trans = new \AGMS\Transaction(); // Specify transaction parameters $params = array( 'transaction_type' => array('value' => 'sale'), 'amount' => array('value' => '20.00'), 'cc_number' => array('value' => '4111111111111111'), 'cc_exp_date' => array('value' => '1220'), ); // Execute the transaction using the defined parameters $result = $trans->process($params); ?>
/** * A basic example of a sale transaction using the AGMS Ruby Library **/ // Include the library require 'agms' // Initialize the library configuration Agms::Configuration.init('init.yml') // Set up the API connection trans = Agms::Transaction.new // Specify transaction parameters params = { :transaction_type => { :value => 'sale'}, :amount => { :value => '20.00'}, :cc_number => { :value => '4111111111111111'}, :cc_exp_date => { :value => '0520'}, :cc_cvv => { :value => '123'} } // Execute the transaction using the defined parameters result = trans.process(params)
/** * A basic example of a sale transaction using the AGMS Python Library **/ // Include the library import 'agms' // Initialize the library configuration agms.Configuration.init('init.init') // Set up the API connection trans = agms.Transaction() // Specify transaction parameters params = { 'transaction_type': {'value': 'sale'}, 'amount': {'value': '20.00'}, 'cc_number': {'value': '4111111111111111'}, 'cc_exp_date': {'value': '0520'}, 'cc_cvv': {'value': '123'} } // Execute the transaction using the defined parameters result = trans.process(params)
#ucase("Coldfusion example here")#
// AGMS Transaction Class Constructor public array \AGMS\Transaction::__construct ( [ string $username [, $password [, $accountnumber [, $apikey ] ] ] ] )
// AGMS Transaction Class Constructor Transaction::initialise ( [ string username [, password [, accountnumber [, apikey ] ] ] ] )
// AGMS Transaction Class Constructor Transaction.__init__( self, [ string username [, password [, accountnumber [, apikey, [client] ] ] ] ] )
The Transaction Class can be instantiated with no parameters, or you can explicitly set the gateway credentials you would like to be used for that transaction. If no credentials are provided, the default credentials configured in init.php will be used.
// AGMS Transaction Class process() method public array \AGMS\Transaction::process ( array $parameters )
// AGMS Transaction Class process() method Transaction::process ( Hash parameters )
// AGMS Transaction Class process() method Transaction.process ( dict parameters )
The AGMS Transaction object has a single method "process" which executes a single transaction according to the parameters set. The type of transaction (sale, refund, etc) is determined by the transaction_type parameter.
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. For the purposes of the Transaction Class, each field will only have a "value" and no other options.
The following fields can be passed into the AGMS Transaction Class to process a transaction. For information on what fields are required for a specific transaction, review Transaction Types.
Parameter | Value | Description |
---|---|---|
transaction_type | sale auth capture void refund credit update adjustment safe only |
Type of transaction to be processed. |
payment_type | creditcard check |
"creditcard" is assumed if no value provided. |
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 for all sales and auths. |
order_description | String | Order description, appears by default on gateway-generated receipts. Recommended for all sales and auths. |
order_id | String | Can be used to tie transactions back to a record/transaction ID in your system. |
tip_amount | Decimal | Required for all adjustment transactions. Any amount provided in this field is added to the "amount" value as part of the total charge to the customer. |
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. |
ip_address | String | IP address of the customer submitting the transaction, highly recommended for ecommerce transactions. |
Parameter | Value | Description |
---|---|---|
cc_number | 15-16 Digit Number | Required for all credit card sales and auths unless track data, encrypted data, or SAFE ID is being provided. No spaces or dashes. |
cc_exp_date | MMYY | Required when sending cc_number. |
cc_cvv | 3-4 Digit Number | Recommended when sending cc_number for added chargeback protection. NEVER store this number in your system, it is prohibited by PCI. |
cc_track_1 | String | Track fields are used when sending unencrypted track data from a swiped transaction. This is highly discouraged in favor of using an encrypted swiper out of security and liability concerns. |
cc_track_2 | String | Track fields are used when sending unencrypted track data from a swiped transaction. This is highly discouraged in favor of using an encrypted swiper out of security and liability concerns. |
cc_track_3 | String | Track fields are used when sending unencrypted track data from a swiped transaction. This is highly discouraged in favor of using an encrypted swiper out of security and liability concerns. |
cc_encrypted_data | String | Encrypted data string provided by an encrypted card reader when swiping a card. This is the officially recommended and supported method of processing swiped transactions. Requires a supported card reader injected with the proper encryption key, contact AGMS for details. |
cc_encrypted_hardware | MAGTEK IDTECH |
Required when sending cc_encrypted_data. |
Parameter | Value | Description |
---|---|---|
safe_action | add_safe update_safe delete_safe |
Used to execute a SAFE action alongside the transaction or when running a "safe only" transaction. See the Features section regarding Customer SAFE for details. |
safe_id | Integer | Required for update_safe or delete_safe to specify to which SAFE record to apply the action. |
Customer's information as it appears on their method of payment.
Parameter | Value | 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 | |
String | Automatic customer email receipts will be sent to this address, if you have them enabled. | |
website | String |
Information for the individual that the product is being shipped to or where the services are being provided. These fields are optional.
Parameter | Value | 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 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 | 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 |
The following fields are returned in an array by the AGMS Transaction Class after executing a transaction using the process method.
Key | Value | Description |
---|---|---|
response_code | Integer | 1 = APPROVAL 2 = DECLINE 10 = VALIDATION ERROR 20 = DATA ERROR OR SYSTEM ERROR 30 = EXCEPTION |
response_message | String | Text description of the response_code. |
transaction_id | 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. |
authorization_code | Integer | Transaction authorization code as provided by the processor. |
avs_result | 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 |
avs_message | String | Text description of the avs_message. |
cvv_result | 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. |
cvv_message | String | Text description of the cvv_message. |
order_id | Integer | The Order ID provided in your transaction request. |
safe_id | Integer | If safe_action was used, a safe_id is returned. |
full_response | String | Full response from live processing host (development purposes). |
post_string | String | Raw poststring sent to live processing host (development purposes). |
gift_balance | Decimal | Not used, reserved for gift card transactions. |
gift_response | String | Not used, reserved for gift card transactions. |
merchant_id | Integer | The ID for your AGMS Gateway account. |
customer_message | String | Internal use only. |
rrn | String | Internal use only. |