You can integrate our iOS Library into your Xcode project using Cocoapods.
pod 'GlobalPayments-iOS-SDK', '~> 1.0',$ pod installIf you prefer not to use a dependency manager, you can manually integrate our iOS Library into your project.
You can find a test suite of code samples for using the iOS SDK in our GitHub repository.
You can find the latest SDK documentation under SDKs & Libraries. For a full list of test cards, see our Test Cards article. Code examples can be found in the API Explorer.
/// 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
}
}During integration, you’ll want to test for specific issuer responses such as "Card Declined." In our Sandbox, you can simulate the response of gateways and Issuers by using specific transaction amounts or card numbers.
For a full list of test cards, see our Test Cards article. If you don’t find what you need to simulate a certain result, contact your account manager.
| Card Number | Card Type | Expiration Date | Security Code |
|---|---|---|---|
| 4263970000005262 | Visa | 12/2025 | 123 |
| 2223000010005780 | MasterCard | 12/2025 | 900 |
| 5425230000004415 | MasterCard | 12/2025 | 123 |