Heartland Payment Systems gateway guide

Quick Start

New to integrating Heartland Payment Systems with Spreedly? Here's your setup guide:

  1. Retrieve your Heartland Payment Systems credentials
    1. Log into your Heartland / Portico account.
    2. Copy your Secret API Key.

      A certification key contains cert and automatically routes requests to the Heartland certification endpoint.

  2. Get familiar with the Spreedly API
    1. Review Spreedly API basics
    2. Understand the core concepts: Gateways, Payment Methods, and Transactions
  3. Add Heartland Payment Systems gateway to Spreedly in sandbox mode
📘

Review this documentation to understand more about how to test transactions.

Additional notes
  • Currency and amounts: Heartland amounts are handled in dollars with cents. A Spreedly amount of 1000 is sent to Heartland as 10.00.
  • Partial captures: A partial capture sends the smaller specified amount using CreditAddToBatch.
  • Partial & multiple refunds: A partial refund sends the smaller amount using CreditReturn. Several refunds can be run against the same original purchase until the total refunded amount reaches the original purchase amount.
  • Bank accounts (ACH): Bank account purchases are supported. Authorize, general credit, and store operations are not supported for bank accounts.
  • Voiding transactions:
    • To void a bank-account purchase, set the check_void gateway-specific field to true (executes CheckVoid).
    • A card void uses CreditVoid.
Installments are not a supported stored-credential reason. A recurring reason is sent as Heartland recurring billing.

Adding Heartland Payment Systems

Required Credentials

CredentialTypeDescription
secret_api_keyString (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 FieldHeartland Portico FieldDescription / Rules
three_ds_versionSecure3D.Version3DS protocol version.
authentication_valueSecure3D.AuthenticationValueCAVV / AAV cryptogram.
ecommerce_indicatorSecure3D.ECIElectronic Commerce Indicator. A leading zero is stripped (e.g., 05 is sent as 5).
directory_server_transaction_idSecure3D.DirectoryServerTxnIdDirectory Server Transaction ID.
  • xid is 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 CreditSale or CreditAuth.
  • When Heartland returns CAVVResultCode, Spreedly maps it to gateway_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 MethodHeartland WalletData.PaymentSource
Network tokenNetworkToken
Apple Pay network tokenApplePay
Google Pay network tokenGooglePayApp
  • Cryptogram: Mapped to WalletData.Cryptogram.
  • ECI: Mapped to WalletData.ECI using the leading-zero removal rule (e.g., 05 becomes 5).

Store and Third-Party Tokens

  • Store operation: Running a store operation asks Heartland to tokenize the card and returns a multi-use token. Spreedly stores this as a third_party_token.
  • Subsequent transactions: Later purchase and authorize requests submit this token in CardData.TokenData.TokenValue.
  • Remove operation: Calling remove deletes the token in Heartland Portico.
  • Card-only: Tokenization via store is 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 Ecommerce MOTO on CreditSale and CreditAuth. A recurring stored-credential reason uses RecurringBilling or RecurringBillingAuth, and that request has no Ecommerce element.

Stored Credentials & Card-on-File (COF)

Specify Spreedly's first-class stored credential fields on purchase or authorize:

  • stored_credential_initiator (cardholder or merchant)
  • stored_credential_reason_type (recurring or unscheduled)

Transaction Routing & Field Mappings

  • When stored_credential_reason_type is recurring, Spreedly submits the transaction as RecurringBilling (for purchase) or RecurringBillingAuth (for authorize), passing RecurringData.OneTime = N.
  • All other reasons submit as standard CreditSale or CreditAuth.
reason_typeinitiatorCardOnFileHeartland Transaction Type
recurringcardholderCRecurringBilling or RecurringBillingAuth
recurringmerchantMRecurringBilling or RecurringBillingAuth
unscheduledcardholderCCreditSale or CreditAuth
unscheduledmerchantMCreditSale or CreditAuth
  • CardBrandTxnId is included when a prior network transaction id is available. CardOnFile is 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.

ValueHeartland
delayed_chargeCardOnFileData.CategoryInd 06
no_showCardOnFileData.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 NameTypeRequiredDescription / Use CaseExample Value
descriptor_nameStringNoStatement descriptor, sent as TxnDescriptor on purchase, authorize, and verify.SPREEDLY*STORE
check_voidBooleanNoUsed on void only. Set to true to void a bank-account (ACH) purchase via CheckVoid.true
company_nameStringNoBusiness/company name on bank-account purchases, sent as CheckName.Spreedly
idempotency_keyStringNoUnique 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_dupStringNoY 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_reqStringNoPass Y to request the Payment Account Reference (PAR) on purchase, authorize, or verify.Y
stored_credential_reason_type_overrideStringNodelayed_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 NameTypeDescription
cavv_result_codeStringHeartland 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 FieldHeartland Source FieldDescription
gateway_transaction_idGatewayTxnIdPrimary transaction identifier from Portico.
response.network_transaction_idCardBrandTxnIdNetwork transaction reference ID for card brand tracking.
response.avs_codeAVSRsltCodeAddress Verification Service response code.
response.cvv_codeCVVRsltCodeCVV / CVC verification result code.
tlidTxnLinkIdTransaction link identifier returned on recurring responses.
response.payment_account_referenceAccountReferencePayment Account Reference (PAR) returned when requested.

Additional resources

📘

If you need support with this gateway, please contact Support at [email protected].

📘



Did this page help you?