Heartland Payment Systems gateway guide
Quick Start
New to integrating Heartland Payment Systems with Spreedly? Here's your setup guide:
- Retrieve your Heartland Payment Systems credentials
- Log into your Heartland / Portico account.
-
Copy your Secret API Key.
A certification key contains cert and automatically routes requests to the Heartland certification endpoint.
- Get familiar with the Spreedly API
- Review Spreedly API basics
- Understand the core concepts: Gateways, Payment Methods, and Transactions
- Add Heartland Payment Systems gateway to Spreedly in sandbox mode
Review this documentation to understand more about how to test transactions.
| Additional notes |
|---|
recurring reason is sent as Heartland recurring billing. |
Adding Heartland Payment Systems
Required Credentials
| Credential | Type | Description |
|---|---|---|
secret_api_key | String (Write-only) | Your Heartland Portico secret API key. Keys containing _cert_ automatically connect to the certification environment. The secret API key is write-only and is not returned in responses. |
Request
curl https://core.spreedly.com/v1/gateways.xml \
-u 'EnvironmentKey:AccessSecret' \
-H 'Content-Type: application/xml' \
-d '<gateway>
<gateway_type>hps</gateway_type>
<secret_api_key>skapi_cert_your_secret_api_key</secret_api_key>
</gateway>'Response
<gateway>
<token>1HPSGATEWAYTOXYZ</token>
<gateway_type>hps</gateway_type>
<name>Heartland Payment Systems</name>
<gateway_specific_fields>
<gateway_specific_field>descriptor_name</gateway_specific_field>
<gateway_specific_field>check_void</gateway_specific_field>
<gateway_specific_field>company_name</gateway_specific_field>
<gateway_specific_field>idempotency_key</gateway_specific_field>
<gateway_specific_field>allow_dup</gateway_specific_field>
<gateway_specific_field>account_reference_req</gateway_specific_field>
<gateway_specific_field>stored_credential_reason_type_override</gateway_specific_field>
</gateway_specific_fields>
<payment_methods>
<payment_method>credit_card</payment_method>
<payment_method>apple_pay</payment_method>
<payment_method>google_pay</payment_method>
<payment_method>bank_account</payment_method>
<payment_method>third_party_token</payment_method>
</payment_methods>
<state>retained</state>
<redacted type="boolean">false</redacted>
<sandbox type="boolean">true</sandbox>
</gateway>The response example is abbreviated. The secret API key is write-only and is not returned.
Purchase (Auth and Capture)
Request
curl 'https://core.spreedly.com/v1/gateways/[gateway_token]/purchase.json' \
-u 'EnvironmentKey:AccessSecret' \
-H 'Content-Type: application/json' \
-d '{
"transaction": {
"payment_method_token": "payment_method_token",
"amount": 1000,
"currency_code": "USD",
"order_id": "ORD-1211",
"email": "[email protected]",
"billing_address": {
"name": "Jane Doe",
"address1": "123 Main Street",
"address2": "Suite 100",
"city": "Austin",
"state": "TX",
"zip": "78701",
"country": "US"
},
"retain_on_success": true
}
}'Advanced Features
Third-Party 3D Secure (3DS2)
Spreedly 3DS Global is supported on both purchase and authorize operations. Heartland does not run its own 3DS challenge. Instead, Spreedly maps completed authentication data into Portico Secure3D.
| Spreedly Field | Heartland Portico Field | Description / Rules |
|---|---|---|
three_ds_version | Secure3D.Version | 3DS protocol version. |
authentication_value | Secure3D.AuthenticationValue | CAVV / AAV cryptogram. |
ecommerce_indicator | Secure3D.ECI | Electronic Commerce Indicator. A leading zero is stripped (e.g., 05 is sent as 5). |
directory_server_transaction_id | Secure3D.DirectoryServerTxnId | Directory Server Transaction ID. |
xidis not sent to Heartland.- Browser fields (such as User-Agent, Accept header, IP address) remain on the Spreedly 3DS request and are not forwarded to
CreditSaleorCreditAuth. - When Heartland returns
CAVVResultCode, Spreedly maps it togateway_specific_response_fields.cavv_result_code.
Network Tokenization
Network tokens (Apple Pay, Google Pay, or direct network tokens) are passed in Heartland's WalletData instead of passing the Primary Account Number (PAN). CVV2 is automatically omitted on network token transactions.
| Payment Method | Heartland WalletData.PaymentSource |
|---|---|
| Network token | NetworkToken |
| Apple Pay network token | ApplePay |
| Google Pay network token | GooglePayApp |
- Cryptogram: Mapped to
WalletData.Cryptogram. - ECI: Mapped to
WalletData.ECIusing the leading-zero removal rule (e.g.,05becomes5).
Store and Third-Party Tokens
- Store operation: Running a
storeoperation asks Heartland to tokenize the card and returns a multi-use token. Spreedly stores this as athird_party_token. - Subsequent transactions: Later
purchaseandauthorizerequests submit this token inCardData.TokenData.TokenValue. - Remove operation: Calling
removedeletes the token in Heartland Portico. - Card-only: Tokenization via
storeis supported for credit and debit cards only. Bank accounts cannot be tokenized.
MOTO (Mail Order / Telephone Order)
To execute a MOTO transaction, set three_ds_exemption_type to moto on the purchase or authorize request:
- Spreedly sends
EcommerceMOTOonCreditSaleandCreditAuth. Arecurringstored-credential reason usesRecurringBillingorRecurringBillingAuth, and that request has noEcommerceelement.
Stored Credentials & Card-on-File (COF)
Specify Spreedly's first-class stored credential fields on purchase or authorize:
stored_credential_initiator(cardholderormerchant)stored_credential_reason_type(recurringorunscheduled)
Transaction Routing & Field Mappings
- When
stored_credential_reason_typeisrecurring, Spreedly submits the transaction asRecurringBilling(for purchase) orRecurringBillingAuth(for authorize), passingRecurringData.OneTime = N. - All other reasons submit as standard
CreditSaleorCreditAuth.
reason_type | initiator | CardOnFile | Heartland Transaction Type |
|---|---|---|---|
recurring | cardholder | C | RecurringBilling or RecurringBillingAuth |
recurring | merchant | M | RecurringBilling or RecurringBillingAuth |
unscheduled | cardholder | C | CreditSale or CreditAuth |
unscheduled | merchant | M | CreditSale or CreditAuth |
CardBrandTxnIdis included when a prior network transaction id is available.CardOnFileis still sent on the first cardholder transaction, when that id does not exist yet.
Delayed charge and no show
On purchase or authorize, set stored_credential_reason_type_override.
| Value | Heartland |
|---|---|
delayed_charge | CardOnFileData.CategoryInd 06 |
no_show | CardOnFileData.CategoryInd 07, plus LodgingData.NoShow Y and LodgingData.Duration 1 |
CategoryInd is sent with CardOnFile, so the transaction also needs stored_credential_initiator set to cardholder or merchant. no_show lodging data is sent on purchase and authorize when the override is no_show.
Payment Account Reference (PAR)
Send the gateway-specific field account_reference_req = Y on purchase, authorize, or verify:
- Heartland returns
AccountReference. - Spreedly stores the result in
transaction.response.payment_account_reference.
Gateway-Specific Fields
Pass gateway-specific fields inside <gateway_specific_fields><hps>...</hps></gateway_specific_fields>.
| Field Name | Type | Required | Description / Use Case | Example Value |
|---|---|---|---|---|
descriptor_name | String | No | Statement descriptor, sent as TxnDescriptor on purchase, authorize, and verify. | SPREEDLY*STORE |
check_void | Boolean | No | Used on void only. Set to true to void a bank-account (ACH) purchase via CheckVoid. | true |
company_name | String | No | Business/company name on bank-account purchases, sent as CheckName. | Spreedly |
idempotency_key | String | No | Unique id for this attempt, sent as Header.ClientTxnId on every action. Portico uses it, with the PAN and amount, to recognize a duplicate. Use a new value for a new charge and the same value to retry the same charge. | ORD-1211-attempt-1 |
allow_dup | String | No | Y or N, sent as AllowDup on purchase, authorize, refund, and general credit. Y allows a second transaction that Portico would otherwise treat as a duplicate. | Y |
account_reference_req | String | No | Pass Y to request the Payment Account Reference (PAR) on purchase, authorize, or verify. | Y |
stored_credential_reason_type_override | String | No | delayed_charge or no_show on purchase and authorize. | delayed_charge |
Purchase Request with Gateway-Specific Fields
XML
curl https://core.spreedly.com/v1/gateways/LlkjmEk0xNkcWrNixXa1fvNoTP4/purchase.xml \
-u 'EnvironmentKey:AccessSecret' \
-H 'Content-Type: application/xml' \
-d '<transaction>
<payment_method_token>01K4WT4PY9VZC26F1D63KHAxyz</payment_method_token>
<amount>1200</amount>
<currency_code>USD</currency_code>
<order_id>ORD-1211</order_id>
<email>[email protected]</email>
<description>Some product</description>
<billing_address>
<name>Jane Doe</name>
<address1>123 Main Street</address1>
<address2>Suite 100</address2>
<city>Austin</city>
<state>TX</state>
<zip>78701</zip>
<country>US</country>
</billing_address>
<stored_credential_initiator>merchant</stored_credential_initiator>
<stored_credential_reason_type>unscheduled</stored_credential_reason_type>
<gateway_specific_fields>
<hps>
<descriptor_name>SPREEDLY*STORE</descriptor_name>
<idempotency_key>ORD-1211-attempt-1</idempotency_key>
<allow_dup>N</allow_dup>
<account_reference_req>Y</account_reference_req>
<stored_credential_reason_type_override>delayed_charge</stored_credential_reason_type_override>
</hps>
</gateway_specific_fields>
</transaction>'Gateway-Specific Response Fields
Response XML
<gateway_specific_response_fields>
<hps>
<cavv_result_code>2</cavv_result_code>
</hps>
</gateway_specific_response_fields>| Field Name | Type | Description |
|---|---|---|
cavv_result_code | String | Heartland CAVVResultCode returned after a 3DS authentication attempt. Present only when returned by Heartland. |
Standard Response Mappings
Heartland fields mapped to standard Spreedly transaction response attributes:
| Standard Response Field | Heartland Source Field | Description |
|---|---|---|
gateway_transaction_id | GatewayTxnId | Primary transaction identifier from Portico. |
response.network_transaction_id | CardBrandTxnId | Network transaction reference ID for card brand tracking. |
response.avs_code | AVSRsltCode | Address Verification Service response code. |
response.cvv_code | CVVRsltCode | CVV / CVC verification result code. |
tlid | TxnLinkId | Transaction link identifier returned on recurring responses. |
response.payment_account_reference | AccountReference | Payment Account Reference (PAR) returned when requested. |
Additional resources
If you need support with this gateway, please contact Support at [email protected].
API endpoint (Production): https://api2.heartlandportico.com/hps.exchange.posgateway/posgatewayservice.asmx
Test endpoint (Certification): https://cert.api2.heartlandportico.com/Hps.Exchange.PosGateway/PosGatewayService.asmx
API version: 1.0
A secret API key that contains
_cert_uses the certification endpoint. Any other key uses production.
Updated 2 days ago

