Add the library into an iOS Swift project
1. Import the “IntegratedPaymentSolutionSDK.framework” into the project
2. In the project, add following dependencies “Link Binary With Libraries” under “Build Phases”
3. Add a URL scheme in “URL Types” under “Info”
Using the library for payment for iOS App
1. Import the SDK
import IntegratedPaymentSolutionSDK
2. Implement the protocol PaymentResultCallback
extension MyViewController: PaymentResultCallback {
func onSuccess(_ paymentResult: PyamentResult) {
// do something
}
func onFailure(_ paymentResult: PyamentResult) {
// do something
}
}
3. Cretae a SpiralPayment object. The apiURL will be provided during account opening.
let payment = SpiralPayment(apiURL)
4. Call the “pay” method with a session ID and a PaymentResultCallback object
payment.pay(sessionId, callback: self as PaymentResultCallback)
5. (For Alipay Only) If Alipay app is installed, a URL will be returned by Alipay Client.Call the “processResultUrl” method with the URL in the function “func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool”
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if payment.isAlipayResultUrl(url) {
payment.processResultUrl(url)
}
return true
}
Class Definition
PaymentResult
Field | Type | Sample |
sessionId | String | MPGSSESSION0002121895830J8251291G62 |
paymentStatus | PaymentStatus | APPROVED |
PaymentStatus
Value | Remark |
APPROVED | |
CANCELLED | |
DECLINED | |
NOT_SUPPORTED | |
UNCONFIRMED | Unable to determine the result and need to make further query at backend |
QUERY_FAILED | Cannot get the required transaction information by the session ID. The transaction is not initialed on the payment APP. |
APP_NOT_INSTALLED | For Octopus, which means the Octopus App is not installed |