EasyPay 1.0.4

EasyPay 1.0.4

Maintained by ndraper.



 
Depends on:
Sentry~> 8.35.0
IOSSecuritySuite= 1.9.11
 

EasyPay 1.0.4

  • By
  • Easy Pay Solutions

README

Easy Pay iOS SDK

Easy Pay library offers access to the Easy Pay API for seamless integration with iOS applications.

General Easy Pay Developer Documentation

Requirements

  • Xcode 15 or above
  • compatible with iOS 13.0 or above

Get started

  1. Prerequisties - obtain from Easy Pay HMAC secret and API key

  2. Configure Easy Pay class for example in your Payment Module or in AppDelegate (didFinishLaunchingWithOptions)

EasyPay.shared.configureSecrets(apiKey: "YOURAPIKEY",
                                hmacSecret: "YOURHMACSECRET")
  1. 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

Installation

  1. Setup with Swift Package Manager
.package(url: "https://github.com/Easy-Pay-Solutions/Mobile-SDK-IOS.git", from: "0.1.0")
  1. Setup with Cocoapods
pod 'EasyPay'

Public methods in EasyPay class

EasyPay.shared.configureSecrets(apiKey: String, hmacSecret: String)
EasyPay.shared.loadCertificate(_ completion: @escaping (Result<Data, Error>) -> Void)

Public methods in ApiClient in EasyPay

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)

Data Classes (Request)

  • ChargeCreditCard
    • TransactionRequest
      • creditCardInfo: CreditCardInfo
      • accountHolder: AccountHolder
      • endCustomer: EndCustomer?
      • amounts: Amounts
      • purchItems: PurchItems
      • merchantId: Int

Data Classes (Response)

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

Data Classes (Request)

  • ListAnnualConsents
    • AnnualQueryHelper
      • merchantId: String
      • customerReferenceId: String?
      • endDate: Date?

Data Classes (Response)

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

Data Classes (Request)

  • CreateAnnualConsent
    • CreateConsentAnnualManualRequestModel
      • creditCardInfo: CreditCardInfo
      • consentAnnualCreate: CreateConsentAnnual
      • accountHolder: AccountHolder
      • endCustomer: AnnualEndCustomer?

Data Classes (Response)

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

Data Classes (Request)

  • CancelAnnualConsent
    • CancelConsentAnnualManualRequestModel
      • consentId: Int

Data Classes (Response)

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

Data Classes (Request)

  • ProcessPaymentAnnualConsent
    • ProcessPaymentAnnualRequestModel
      • consentId: Int
      • processAmount: String

Data Classes (Response)

  • ProcessPaymentAnnualConsent
    • ProcessPaymentAnnualResponseModel

SecureTextField

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()

How to properly consume the API response

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.

Possible Errors

RsaCertificateError

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

AuthenticationError

Error name Suggested solution
missingSessionKeyOrExpired Check if you have provided correct api key and hmacSecret, contact with Easy Pay to receive updated secrets

NetworkingError

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

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.