iOS SDK
Getting started with iOS SDK for Number
Last updated
Was this helpful?
Getting started with iOS SDK for Number
Last updated
Was this helpful?
The EasyPay iOS SDK offers access to the Number API for effortless integration with any iOS application. For Android integration, refer to the Android SDK integration guide.
Xcode 15 or above
Compatible with iOS 13.0 or above
Setup with Swift Package Manager
Setup with Cocoapods
Prerequisites - get HMAC secret, API key and optional Sentry DSN from Number.
During the initialization, the process of downloading the certificate is starting. Proceeding with any call before downloading has finished will result in an error RsaCertificateError.failedToLoadCertificateData
.
You can check the status of downloading by accessing the following enum:
To enable jailbreak detection, please set isProduction = true
when initializing the library and add the following URL schemes to main Info.plist
.
Number's prebuilt payment UI components allow you to collect and process credit card information and payments in a secure way.
For managing saved cards without paying, the following initializer should be used:
preselectedCardId
is an optional parameter that allows to mark a card as selected by passing the ConsentId
of this card. If nil or incorrect, the selection will be ignored.
paymentDetails
parameter is used for passing additional payment details not visible for the end user. Either customerReferenceId
or rpguid
must be provided to get the list of consents of a specific customer. In case of of incorrect initialization data, CardSelectionViewControllerInitError
will be thrown.
If you would like to receive callbacks, conform to CardSelectionDelegate
with following methods:
For managing saved cards and paying, following initializer should be used:
amount
should be higher than 0 and it is required parameter.
preselectedCardId
is an optional parameter that allows to mark a card as selected by passing the ConsentId
of this card. If nil or incorrect, the selection will be ignored.
paymentDetails
parameter is used for passing additional payment details not visible for the end user. Either customerReferenceId
or rpguid
must be provided to get the list of consents of a specific customer. In case of of incorrect initialization data, CardSelectionViewControllerInitError
will be thrown.
If you would like to receive callbacks, conform to CardPaymentDelegate
with following methods:
The SDK's widgets use a component called SecureTextField
which ensures a safe input of credit card numbers. It is a subclass of UITextField
which enables freedom of styling as needed.
Setting up requires configuring the certificate once it was downloaded to encrypt credit card data.
To receive the encrypted card string required to send to the API, you can use the following method:
Data in the SecureTextField component is already encrypted and can be used in the API calls without any additional encryption.
Below you'll find code describing some of the objects that are commonly used in requests or responses. You can use it as a reference. The code includes parameter names and types.
CreditCardInfo
The object consists of the following fields:
AccountHolder
The object consists of the following fields:
BillingAddress
The object consists of the following fields:
EndCustomer
The object consists of the following fields:
EndCustomerBillingAddress
The object consists of the following fields:
Amounts
The object consists of the following fields:
PurchItems
The object consists of the following fields:
CreateConsentAnnual
The object consists of the following fields:
AnnualEndCustomer
The object consists of the following fields:
AnnualEndCustomerBillingAddress
The object consists of the following fields:
These methods allow you to configure the SDK secrets and load the certificate.
This method processes a credit card card sale when the credit card details are entered manually. Details include the card number, expiration date, CVV, card holder name and address.
TransactionRequest
creditCardInfo
: CreditCardInfo
accountHolder
: AccountHolder
endCustomer
: EndCustomer?
amounts
: Amounts
purchItems
: PurchItems
merchantId
: Int
The response will be serialized to CardSaleManualResponseModel
and include:
A query that returns annual consent details. Depending on the query sent, a single consent or multiple consents may be returned.
AnnualQueryHelper
merchantId
: String
customerReferenceId
: String?
rpguid
: String?
endDate
: Date?
Either customerReferenceId
or rpguid
must be provided to get the list of consents of a specific customer.
The response will be serialized to ConsentAnnualListingResponseModel
and include:
And the ConsentAnnual
consists of the following fields:
This method creates an annual consent by sending the credit card details, which include: card number, expiration date, CVV, and card holder contact data. It is not created by swiping the card through a reader device.
CreateConsentAnnualManualRequestModel
creditCardInfo
: CreditCardInfo
consentAnnualCreate
: CreateConsentAnnual
accountHolder
: AccountHolder
endCustomer
: AnnualEndCustomer?
The response will be serialized to CreateConsentAnnualResponseModel
and include:
Cancels an annual consent. Credit card data is removed from the system after the cancellation is complete.
CancelConsentAnnualManualRequestModel
consentId
: Int
The response will be serialized to CancelConsentAnnualResponseModel
and include:
This method uses the credit card stored on file to process a payment for an existing consent.
ProcessPaymentAnnualRequestModel
consentId
: Int
processAmount
: String
The response will be serialized to ProcessPaymentAnnualResponseModel
and include:
The response must be consumed in the intended order and format. Clients who deviate from this can experience unwanted behavior.
If there is no TxApproved
flag, then you can omit the last evaluation. More information about consuming the API response can be found in Consuming the API response section.
failedToLoadCertificateData
Check certificate status, wait until the full download before proceeding with calls, try to download it again manually.
failedToCreateCertificate
Contact Number.
failedToExtractPublicKey
Contact Number.
missingSessionKeyOrExpired
Check if you have provided the correct apiKey
and hmacSecret
, contact Number to receive updated secrets.
unsuccesfulRequest
Check HTTP status code.
noDataReceived
Data from backend was empty, contact Number.
dataDecodingFailure
Data from backend was not decoded properly, contact Number.
invalidCertificatePathURL
Contact Number.
The SDK follows semantic versioning with a three-part version number: MAJOR
.MINOR
.PATCH
.
MAJOR
version is incremented when there are incompatible API changes,
MINOR
version is incremented when functionality is added in a backwards-compatible manner,
PATCH
version is incremented when there are backwards-compatible bug fixes.
REST API equivalent:
REST API equivalent:
REST API equivalent:
REST API equivalent:
REST API equivalent:
Configure EasyPay
class. You can do that in your Payment Module or in AppDelegate
(didFinishLaunchingWithOptions
). Set isProduction = true
to enable jailbroken device detection.