Developer Portal

Credit Card Payments

The Heartland SDK is compatible with semi-integrated devices that connect directly with Heartland, providing a variety of methods which make performing transactions simple and easy, keeping all payment data away from the Point of Sale software. With the Heartland SDK library, you can quickly implement Credit, Debit, and Gift/Loyalty capabilities into your Heartland integrations.

Connecting to Device

The SDK supports communication with the Semi-integrated Devices. The ConnectionConfig object is used by the SDK to define device communication protocols. To configure the connection, you will need to select a ConnectionMode and supply any additional pertinent information for the mode specified. Please refer to your device documentation for supported connection modes.

Device setup

// see .Net/Java
// RequestIdProvider
using GlobalPayments.Api.Terminals;
public class RequestIdProvider : IRequestIdProvider {
                private Random random;
                public RequestIdProvider() { 
                random = new Random(DateTime.Now.Millisecond);
                }
                public int GetRequestId() {
                return new Random().Next(100000, 999999);
                }
}
// Device connection
var device = DeviceService.Create(new ConnectionConfig {
                DeviceType = DeviceType.HPA_ISC250,
                ConnectionMode = ConnectionModes.TCP_IP,
                IpAddress = "10.12.220.130",
                Port = "12345",
                TimeOut = 30000,
                RequestIdProvider = new RequestIdProvider()
});
// RequestIdProvider
import java.util.Random;
import org.joda.time.DateTime;
import com.global.api.terminals.IRequestIdProvider;
public class RequestIdProvider implements IRequestIdProvider {
                private Random random;
                public RequestIdProvider() { 
                random = new Random(DateTime.now().getMillisOfSecond());
                }
                public int getRequestId() { 
                return 100000 + random.nextInt(999999);
                }
}
// Device configuration
import com.global.api.entities.enums.ConnectionModes;
import com.global.api.entities.enums.DeviceType;
import com.global.api.services.DeviceService;
import com.global.api.terminals.ConnectionConfig;
import com.global.api.terminals.abstractions.IDeviceInterface;
ConnectionConfig deviceConfig = new ConnectionConfig();
deviceConfig.setDeviceType(DeviceType.HPA_ISC250);
deviceConfig.setConnectionMode(ConnectionModes.TCP_IP);
deviceConfig.setIpAddress("10.12.220.130");
deviceConfig.setPort(12345);
deviceConfig.setTimeout(30000);
deviceConfig.setRequestIdProvider(new RequestIdProvider());
IDeviceInterface device = DeviceService.create(config);
# see .Net/Java
# see .Net/Java
// see .Net/Java
#import "HpsHpaDevice.h"

HpsConnectionConfig *config = [[HpsConnectionConfig alloc] init];
config.ipAddress = @"10.12.220.172";
config.port = @"10009";
config.connectionMode = HpsConnectionModes_TCP_IP;
HpsHpaDevice * device = [[HpsHpaDevice alloc] initWithConfig:config];

Credit Sale

CreditSale authorizes a credit card transaction. These authorizations are automatically added to the batch to be settled. If a batch is not already open, this transaction will create one.

Credit Sale Example

// see .Net/Java
var response = device.CreditSale(11m)
                .Execute();
import com.global.api.terminals.TerminalResponse;
import java.math.BigDecimal;
TeminalResponse response = device.creditSale(new BigDecimal("11"))
                .execute();
# see .Net/Java
# see .Net/Java
// see .Net/Java
HpsHpaCreditSaleBuilder *builder = [[HpsHpaCreditSaleBuilder alloc] initWithDevice:device];
builder.amount = [NSNumber numberWithDouble:11.0];
builder.referenceNumber = 1;
builder.creditCard = card;
builder.address = address;
[builder execute:^(HpsHpaCreditResponse *payload, NSError *error) {}];

Next Steps

Learn more about credit and debit card payments with: