要运行示例项目,请克隆 repo,并首先从 Example 目录运行 pod install
。然后输入您的 LeatherBack 公钥以进行测试
LAAS 可通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile
pod 'LAAS'
通过 SPM 获取 LAAS 的最新版本。
转到 File -> Swift Packages -> Add Package Dependency...
然后输入此软件包的 URL https://github.com/leatherback01/AaaS_iOS_SDK.git
并选择最新版本。
import LAAS
let param = LeatherBackTransactionParam(amount: 1.50, currencyCode: .GBP, channels: [.Card, .Account], showPersonalInformation: true, reference: "your unique reference number", key: "your public key", isProducEnv: false)
let paymentVC = LeatherBackViewController(delegate: self, param: param)
present(paymentVC, animated: true)
let param = LeatherBackTransactionParam(amount: 1500.00, currencyCode: .NGN, channels: [.Card, .Account], showPersonalInformation: false, reference: "your unique reference number", customerEmail: "johndoe@leatherback.co", customerName: "John Doe", key: "your public key", isProducEnv: false)
let paymentVC = LeatherBackViewController(delegate: self, param: param)
present(paymentVC, animated: true)
要从 LeatherBackViewController
接收事件,您的 presenting viewcontroller 需要符合 LeatherBackDelegate
class ViewController: UIViewController, LeatherBackDelegate {
func onLeatherBackError(error: LeatherBackErrorResponse) {
print("error \(error.localizedDescription)")
}
func onLeatherBackSuccess(response: LeatherBackResponse) {
//Use this reference to verify payment/transaction with LeatherBack
print("success \(response.reference)")
}
func onLeatherBackDimissal() {
print("dismissed")
}
}
如果 showPersonalInformation
设置为 false
,则商家需要提供客户的姓名和电子邮件地址,但如果 showPersonalInformation
设置为 true
,LeatherBack 将在结账期间从客户那里收集此信息。
如果 reference
设置为空字符串,则默认为 nil
,但 onLeatherBackSuccess delegate method
将返回一个可用于验证交易/付款的 reference
如果 isProducEnv
设置为 true,您需要传递生产密钥;如果设置为 false,您需要传递测试密钥
如果 channels
设置为 nil,结账将返回所有付款方式选项
amount: Double // required
currencyCode: Currency // required
key: String // required
showPersonalInformation: Bool // required
isProducEnv: Bool // required
channels:[PaymentChannels] // optional
reference: String // optional
customerEmail: String // optional
customerName: String // optional
LAAS 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。