Easy Pay library offers access to the Easy Pay API for seamless integration with iOS applications.
General Easy Pay Developer Documentation
- Xcode 15 or above
- compatible with iOS 13.0 or above
-
Prerequisties - obtain from Easy Pay HMAC secret and API key
-
Configure Easy Pay class for example in your Payment Module or in AppDelegate (didFinishLaunchingWithOptions)
EasyPay.shared.configureSecrets(apiKey: "YOURAPIKEY",
hmacSecret: "YOURHMACSECRET")
- Please mind that during Easy Pay initilization the process of downloading certificate is starting. Proceeding with any call before downloading has finished will result in error (RsaCertificateError.failedToLoadCertificateData). You can check the status of downloading by accessing following enum:
EasyPay.shared.certificateStatus
- Setup with Swift Package Manager
.package(url: "https://github.com/Easy-Pay-Solutions/Mobile-SDK-IOS.git", from: "0.1.0")
- Setup with Cocoapods
pod 'EasyPay'
EasyPay.shared.configureSecrets(apiKey: String, hmacSecret: String)
EasyPay.shared.loadCertificate(_ completion: @escaping (Result<Data, Error>) -> Void)
1. Charge Credit Card - CreditCardSale_Manual Easy Pay API Documentation.
Processes a credit card cardsale when the credit card details are entered manually. Details include the card number, expiration date, CVV, card holder name and address.
EasyPay.apiClient.chargeCreditCard(request: CardSaleManualRequest,
completion: @escaping (Result<CreditCardSaleResponse, Error>) -> Void)
- ChargeCreditCard
- TransactionRequest
- creditCardInfo: CreditCardInfo
- accountHolder: AccountHolder
- endCustomer: EndCustomer?
- amounts: Amounts
- purchItems: PurchItems
- merchantId: Int
- TransactionRequest
- ChargeCreditCard
- CardSaleManualResponseModel
2. List Annual Consents - ConsentAnnual_Query Easy Pay API Documentation.
A query that returns annual consent details. Depending upon the query sent, a single consent or muliple consents may be returned.
EasyPay.apiClient.listAnnualConsents(request: ConsentAnnualListingRequest,
completion: @escaping (Result<ListingConsentAnnualResponse, Error>) -> Void)
- ListAnnualConsents
- AnnualQueryHelper
- merchantId: String
- customerReferenceId: String?
- endDate: Date?
- AnnualQueryHelper
- ListAnnualConsents
- ConsentAnnualListingResponseModel
3. Create Annual Consent - ConsentAnnual_Create_MAN Easy Pay API Documentation.
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.
EasyPay.apiClient.createAnnualConsent(request: CreateConsentAnnualRequest,
completion: @escaping (Result<CreateConsentAnnualResponse, Error>) -> Void)
- CreateAnnualConsent
- CreateConsentAnnualManualRequestModel
- creditCardInfo: CreditCardInfo
- consentAnnualCreate: CreateConsentAnnual
- accountHolder: AccountHolder
- endCustomer: AnnualEndCustomer?
- CreateConsentAnnualManualRequestModel
- CreateAnnualConsent
- CreateConsentAnnualResponseModel
4. Cancel Annual Consent - ConsentAnnual_Cancel Easy Pay API Documentation.
Cancels an annual consent. Credit card data is removed from the system after the cancellation is complete.
EasyPay.apiClient.cancelAnnualConsent(request: CancelConsentAnnualRequest,
completion: @escaping (Result<CancelConsentAnnualResponse, Error>) -> Void)
- CancelAnnualConsent
- CancelConsentAnnualManualRequestModel
- consentId: Int
- CancelConsentAnnualManualRequestModel
- CancelAnnualConsent
- CancelConsentAnnualResponseModel
5. Process Payment Annual Consent - ConsentAnnual_ProcPayment Easy Pay API Documentation.
This method uses the credit card stored on file to process a payment for an existing consent.
EasyPay.apiClient.processPaymentAnnualConsent(request: ProcessPaymentAnnualRequest,
completion: @escaping (Result<ProcessPaymentAnnualResponse, Error>) -> Void)
- ProcessPaymentAnnualConsent
- ProcessPaymentAnnualRequestModel
- consentId: Int
- processAmount: String
- ProcessPaymentAnnualRequestModel
- ProcessPaymentAnnualConsent
- ProcessPaymentAnnualResponseModel
SDK contains component called SecureTextField prepared to ensure safe input of number of credit card details. It is a subclass of UITextField which enables freedom of styling as needed.
Setting up requires configuring certificate once it was downloaded to encrypt credit card data.
nameOfYourTextField.setupConfig(EasyPay.shared.config)
To receive encrypted card string required to send to the API you can use following method:
nameOfYourTextField.encryptCardData()
It is critical that the response is consumed in the intended order and format. Clients who deviate from this can experience unwanted behavior.
if response.data.errorMessage != "" && response.data.errorCode != 0 {
//This indicates an error which was handled on the EasyPay servers, consume the ErrCode and the ErrMsg
return
} else if response.data.functionOk == true && response.data.txApproved == false {
//This indicates a declined authorization, display the TXID, RspMsg (friendly decline message), also the decline Code (TxnCode)
} else {
//Transaction has been approved, display the TXID, and approval code (also in TXNCODE)
}
For all other calls you will consume the response the same. If there is No TxApproved flag, then you can omit the last evaluation.
Error name | Suggested solution |
---|---|
failedToLoadCertificateData | Check certificate status, wait until is being downloaded before proceeding with calls, try to download it again manually |
failedToCreateCertificate | Contact Easy Pay |
failedToExtractPublicKey | Contact Easy Pay |
Error name | Suggested solution |
---|---|
missingSessionKeyOrExpired | Check if you have provided correct api key and hmacSecret, contact with Easy Pay to receive updated secrets |
Error name | Suggested solution |
---|---|
unsuccesfullRequest | Check HTTP status code |
noDataReceived | Data from backend was empty, contact Easy Pay |
dataDecodingFailure | Data from backend was not decoded properly, contact with Easy Pay |
invalidCertificatePathURL | Contact Easy Pay |
Semantic versioning follows a three-part version number: MAJOR.MINOR.PATCH.
Increment the:
- MAJOR version when you make incompatible API changes,
- MINOR version when you add functionality in a backwards-compatible manner, and
- PATCH version when you make backwards-compatible bug fixes.