The secux-paymentkit-sample-for-springtrees-ios is a sample APP for showing how to scan the QRCode from P22 and confirm the promotion / payment / refill to the P22 device via secux-paymentkit-v2.
To run the example project, clone the repo, and run pod install
from the Example directory first.
iOS 12+ , Swift 5
secux-paymentkit-v2 is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'secux-paymentkit-v2'
import secux_paymentkit_v2
import secux_paymentdevicekit
Create SecuXAccountManager object
let accManager = SecuXAccountManager()
- Merchant Login
Must login the assigned merchant account before calling payment related APIs.
Note: Login session is valid for 30 minutes. To continue use after 30 minutes, relogin is required.
SecuX Server API: /api/Admin/Login
func loginMerchantAccount(accountName:String, password:String)
-> (SecuXRequestResult, Data?)
accountName: Merchant account name.
password: Merchant account password.
SecuXRequestResult shows the operation result. If the result is SecuXRequestOK,
login is successful, otherwise login failed and data might contain an error message.
func login(name:String, password:String) -> Bool{
let (ret, data) = accountManager.loginMerchantAccount(accountName: name,
password: password)
guard ret == SecuXRequestResult.SecuXRequestOK else{
print("login failed!")
if let data = data,
let error = String(data: data, encoding: String.Encoding.utf8) {
print("Error: \(error)")
}
return false
}
return true
}
Create SecuXPaymentManager object
let paymentManager = SecuXPaymentManager()
- Get store information
Get store information via the hashed device ID in P22 QRCode.
SecuX Server API:
func getStoreInfo(devID:String)
-> (SecuXRequestResult, String, SecuXStoreInfo?)
devID: Hashed device ID from P22 QRCode
SecuXRequestResult shows the operation result. If the result is SecuXRequestOK,
getting store information is successfully, store information is in the SecuXStoreInfo,
otherwise getting store information is failed and string might contain an error message.
Note: if return result is SecuXRequestNoToken / SecuXRequestUnauthorized, the login
session is timeout, please relogin the system.
SecuXStoreInfo contains store code, store name, store icon, store device id and
store supported coin/token array
let (ret, error, storeInfo) = paymentManager.getStoreInfo(devID: devIDHash)
guard ret == SecuXRequestResult.SecuXRequestOK else{
self.showMessageInMainThread(title: "Get store info. failed!",
message: "Error: \(error)")
return
}
guard let devID = storeInfo?.devID else{
self.showMessageInMainThread(title: "Invalid store info. no device ID",
message: "")
return
}
- Do check-in / promotation / payment / refill operation
Confirm the check-in/promotation/payment/refill operation to the P22 device.
2.1 SecuX Server APIs:
-
Login operator account /api/Admin/Login
-
Encrypt operation data /api/B2B/ProduceCipher
2.2 SecuX Device APIs:
Please refer to the secux_paymentdevicekit for the APIs below:
-
Get P22 ivKey
-
Cancel operation
-
Send encrypted operation data to P22
maochuns, [email protected]
secux-paymentkit is available under the MIT license.