PaystackCheckout 0.1.1

PaystackCheckout 0.1.1

Jubril O 维护。



  • 作者
  • Jubril Olambiwonnu

PaystackCheckout

示例

要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install

要求

Paystack Checkout 需要 Xcode 11.7 或更高版本,并兼容针对 iOS 11 或更高版本的 app。

安装

PaystackCheckout 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod 'PaystackCheckout'

使用

要收取用户的付款,请创建一个 CheckoutViewController 实例,设置其 TransactionParamsdelegate

let params = TransactionParams(amount: 5000, email: "[email protected]", key: "pk_live_xxxx")
let checkoutVC = CheckoutViewController(params: params, delegate: self)
present(checkoutVC, animated: true)

TransactionParams类封装了初始化交易所需的所有参数。以下参数是必需的:amount(金额)、email(邮箱)和publicKey(公钥)。所有其他参数都是可选的。参数的完整列表及其功能可在以下位置找到。

要接收来自CheckoutViewController的事件,呈现视图控制器需要遵守CheckoutProtocol

class ViewController: UIViewController, CheckoutProtocol {

  func onSuccess(response: TransactionResponse) {
    print("Payment successfull \(response.reference)")
  }
  
  func onError(error: Error?) {
    print("There was an error: \(error!.localizedDescription)")
  }
    
  func onDimissal() {
    print("You dimissed the payment modal")
  }
}