Developer Portal

Gift Card Payments

Follow these steps to take gift card payments using your language of choice on one of our terminals.

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];

Gift Sale Example

// see .Net/Java
var response = device.GiftSale(10m)
    .Execute();
import com.global.api.terminals.TerminalResponse;
import java.math.BigDecimal;

TerminalResponse response = device.giftSale(new BigDecimal("10"))
    .execute();
# see .Net/Java
# see .Net/Java
// see .Net/Java
HpsHpaGiftSaleBuilder *builder = [[HpsHpaGiftSaleBuilder alloc] initWithDevice:device];
builder.amount = [NSNumber numberWithDouble:10.0];
builder.referenceNumber = 1;
builder.giftCard = card;

[builder execute:^(HpsHpaGiftResponse *payload, NSError *error) {
}];

Next Steps

Learn more about gift card payments with: