Loading...
/// Prepare required configuration
GpApiConfig config = new GpApiConfig();
config.setServiceUrl("Service Url"); //(Sandbox URL: "https://apis.sandbox.globalpay.com/ucp")
config.setAppId("Your application ID");
config.setAppKey("Your application key");
/// Add config to container
ServicesContainer.configureService(config);
/// Prepare card
CreditCardData card = new CreditCardData();
card.setNumber("4111111111111111");
card.setExpMonth(12);
card.setExpYear(2025);
card.setCvn("123");
// Execute operation
Transaction transaction = card.charge(new BigDecimal("19.99"))
.withCurrency("USD")
.execute();/// Prepare required configuration
let config = GpApiConfig (
appId: "Your application ID",
appKey: "Your application key"
)
/// Add config to container
try ServicesContainer.configureService(config: config)
/// Prepare card
let card = CreditCardData()
card.number = "4111111111111111"
card.expMonth = 12
card.expYear = 2025
card.cvn = "123"
card.cardHolderName = "Joe Smith"
// Execute operation
card.charge(amount: 19.99)
.withCurrency("USD")
.execute { transaction, error in
// Handle transaction response or error
}card.charge(amount: 19.99)
.withCurrency("USD")
.withAddress(address)
.execute { transaction, error in
if let error = error as? BuilderException {
// handle builder errors
} else if let error = error as? ConfigurationException {
// handle errors related to your services configuration
} else if let error = error as? GatewayException {
// handle gateway errors/exceptions
} else if let error = error as? UnsupportedTransactionException {
// handle errors when the configured gateway doesn't support desired transaction
} else if let error = error as? ApiException {
// handle all other errors
}
}