Requirements
- You must be a client of ePay.
- You must obtain integration data:
TerminalID | Merchant payment terminal ID |
---|---|
ClientID | Merchant ID |
ClientSecret | Merchant Secret Key |
- The deployment target of your project should be iOS 11 or higher.
Test data
ClientID | test |
---|---|
ClientSecret | yF587AV9Ms94qN2QShFzVR3vFnWkhjbAK3sG |
TerminalID | 67e34d63-102f-4bd1-898e-370781d0074d |
Setup
1. Import SDK
- Download EpaySDK.framework from the linkIOS framework
- Unzip the archive
- Add EpaySDK.framework to your project
3.1 In the Embed Frameworks target of your application, you need to import and add the EpaySDK.framework library.
2. Setup Auth Configs
Create an instance of authentication configs. You can store the instance in constants or create it during direct initialization of the Payment Page or Transfer Page
Import the EpaySDK module.
import EpaySDK
Create an AuthConfig instance
let config = AuthConfig(
merchantId: <The store's TerminalID identifier received from epay>,
merchantName: <Store Name>,
clientId: <Client identifier ClientID received from epay>,
clientSecret: <clientSecret secret key received from epay>
)
3. Response handling from EpaySDK.
Add an observer to handle the response from EpaySDK.
NotificationCenter.default.addObserver(
self,
selector: #selector(handleSdkResponse),
name: Notification.Name("sdk_response"),
object: nil)
Note: The notification type must be sdk_response, but you can change the name of the handler method handleSdkResponse
4. Response handling
Create a function to handle the notification for the result of the payment/transfer processing (function handleSdkResponse from the previous step).
Response format:
isSuccessful: Bool, paymentReference: String, errorCode: Int, errorMessage: String
Example handler:
@objc func handleSdkResponse(_ notification: Notification) {
navigationController?.popToViewController(self, animated: true) // 1
let isSuccessful = notification.userInfo?["isSuccessful"] as? Bool // 2
if isSuccessful == true { // 3
let reference = notification.userInfo?["paymentReference"] as? String
} else { // 4
let errorCode = notification.userInfo?["errorCode"] as? Int
let errorMessage = notification.userInfo?["errorMessage"] as? String
}
Where the steps are:
- Exit from SDK
- Determine the payment status
- If successful, get the payment reference
- Otherwise, get the error code and message
5. Setting up payment or transfer
Next, to make a direct operation, you need to prepare a payment model and launch the type of operation you need. Learn more on the Payment Pages and Transfer Pages pages.