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

1

Setup with Swift Package Manager

.package(url: "https://github.com/Easy-Pay-Solutions/Mobile-SDK-IOS.git", from: "1.0.6")
2

Setup with Cocoapods

pod 'EasyPay'


Get started

Integration

1

Prerequisites - get HMAC secret, API key and optional Sentry DSN from Number.

2
3

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:

4

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:

Data in the SecureTextField component is already encrypted and can be used in the API calls without any additional encryption.


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

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:


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

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

  • 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.

Response body

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.

REST API equivalent: Create Annual Consent

Request body

Response body

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.

REST API equivalent: Consent Annual Older

Request parameters

  • CancelConsentAnnualManualRequestModel

    • consentId: Int

Response body

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.

REST API equivalent: Consent Annual Older

Request body

  • ProcessPaymentAnnualRequestModel

    • consentId: Int

    • processAmount: 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

Error name
Suggested solution

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

Error name
Suggested solution

missingSessionKeyOrExpired

Check if you have provided the correct apiKey and hmacSecret, contact Number to receive updated secrets.

NetworkingError

Error name
Suggested solution

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.

  • 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.

Last updated

Was this helpful?