iOS SDK
Getting started with iOS SDK for Number
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.
Installation
Requirements
Xcode 15 or above
Compatible with iOS 13.0 or above
Configuration
Setup with Swift Package Manager
.package(url: "https://github.com/Easy-Pay-Solutions/Mobile-SDK-IOS.git", from: "1.0.6")Setup with Cocoapods
pod 'EasyPay'Get started
Integration
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.
Using widgets
Number's prebuilt payment UI components allow you to collect and process credit card information and payments in a secure way.
Managing cards
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:
Managing cards and payment
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:
Screenshots
Save Card


Manage Cards


Store and Pay


Common components
SecureTextField component
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:
Common objects
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
CreditCardInfoThe object consists of the following fields:
AccountHolder
AccountHolderThe object consists of the following fields:
BillingAddress
BillingAddressThe object consists of the following fields:
EndCustomer
EndCustomerThe object consists of the following fields:
EndCustomerBillingAddress
EndCustomerBillingAddressThe object consists of the following fields:
Amounts
AmountsThe object consists of the following fields:
PurchItems
PurchItemsThe object consists of the following fields:
CreateConsentAnnual
CreateConsentAnnualThe object consists of the following fields:
AnnualEndCustomer
AnnualEndCustomerThe object consists of the following fields:
AnnualEndCustomerBillingAddress
AnnualEndCustomerBillingAddressThe object consists of the following fields:
Publics methods in the SDK
Configuration
These methods allow you to configure the SDK secrets and load the certificate.
1. Charge credit card
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.
REST API equivalent: Process a Card Sale Old
Request parameters
TransactionRequestcreditCardInfo: CreditCardInfoaccountHolder: AccountHolderendCustomer: EndCustomer?amounts: AmountspurchItems: PurchItemsmerchantId: Int
Response body
The response will be serialized to CardSaleManualResponseModel and include:
2. List annual consents
A query that returns annual consent details. Depending on the query sent, a single consent or multiple consents may be returned.
REST API equivalent: Query Old
Request body
AnnualQueryHelpermerchantId: StringcustomerReferenceId: String?rpguid: String?endDate: Date?
Either
customerReferenceIdorrpguidmust be provided to get the list of consents of a specific customer.
Response body
The response will be serialized to ConsentAnnualListingResponseModel and include:
And the ConsentAnnual consists of the following fields:
3. Create annual consent
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.
REST API equivalent: Create Annual Consent
Request body
CreateConsentAnnualManualRequestModelcreditCardInfo: CreditCardInfoconsentAnnualCreate: CreateConsentAnnualaccountHolder: AccountHolderendCustomer: AnnualEndCustomer?
Response body
The response will be serialized to CreateConsentAnnualResponseModel and include:
4. Cancel annual consent
Cancels an annual consent. Credit card data is removed from the system after the cancellation is complete.
REST API equivalent: Consent Annual Older
Request parameters
CancelConsentAnnualManualRequestModelconsentId: Int
Response body
The response will be serialized to CancelConsentAnnualResponseModel and include:
5. Process payment for an annual consent
This method uses the credit card stored on file to process a payment for an existing consent.
REST API equivalent: Consent Annual Older
Request body
ProcessPaymentAnnualRequestModelconsentId: IntprocessAmount: String
Response body
The response will be serialized to ProcessPaymentAnnualResponseModel and include:
How to properly consume the API response
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.
Possible errors
RsaCertificateError
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.
AuthenticationError
missingSessionKeyOrExpired
Check if you have provided the correct apiKey and hmacSecret, contact Number to receive updated secrets.
NetworkingError
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.
Semantic versioning
The SDK follows semantic versioning with a three-part version number: MAJOR.MINOR.PATCH.
MAJORversion is incremented when there are incompatible API changes,MINORversion is incremented when functionality is added in a backwards-compatible manner,PATCHversion is incremented when there are backwards-compatible bug fixes.
Last updated
Was this helpful?