PaySky PayButton SDK
PayButton帮助您将卡片接受集成到您的应用中变得简单。
您只需将您从PaySky收到的商户信息提供给支付SDK。PayButton会显示一个准备好的视图,引导商户完成支付流程,并在交易结束时显示摘要页面。
入门指南
先决条件
此项目使用cocoapods进行依赖项管理。如果您机器上没有安装cocoapods或使用的是较旧版本的cocoapods,您可以通过在终端中运行命令sudo gem install cocoapods
来安装它。更多信息,请访问https://cocoapods.org.cn/
- 如果您的机器上还没有安装CocoaPods,请在您的机器上下载它。
sudo gem install cocoapods
- 为您的项目创建一个Podfile。
pod init
- 使用
pod
安装第三方库
pod install
💻 安装
- 将pod添加到您的Podfile中
pod 'PayButton'
- 打开终端并运行
pod deintegrate
pod clean
pod install
🚀 部署
- 在将您的项目部署上线之前,您应该从我们公司获取一个商家ID和终端ID。
- 您应该在项目中妥善保管您的商家ID和终端ID,在保存到项目中之前进行加密。
🛠 如何使用
为了使用SDK,您需要从PaySky公司获取商家ID、终端ID和安全哈希密钥。
👉 导入
在您想要发起支付的类中,您应该导入框架
import PayButton
导入后,从PayButton创建一个新实例
let paymentViewController = PaymentViewController()
并在PayButton实例中初始化以下数据:-
- 商家ID
- 终端ID
- 安全哈希
- 交易参考号
- 支付金额
- 货币代码[可选]
paymentViewController.delegate = self // Payment Delegate
paymentViewController.mId = "merchantId" // Merchant id
paymentViewController.tId = "terminalId" // Terminal id
paymentViewController.Key = "Merchant secure hash" // Merchant secrue hash
paymentViewController.refnumber = "reference number" // Generate unique 16-digits number
paymentViewController.amount = "amount" // Amount
paymentViewController.Currency = "currencyCode" // Currency Code [Optional]
paymentViewController.pushViewController()
为了在 PaymentDelegate 代理中创建交易回调,请在您的 ViewController 上实现代理。
class ViewController: UIViewController, PaymentDelegate {
func finishSdkPayment(_ receipt: TransactionStatusResponse) {
if receipt.Success { // if transaction success is true
print("Transaction completed successfully")
print(receipt.NetworkReference) // reference number of transaction.
} else {
print("Transaction failed")
print(receipt.Message) // response error
}
}
}
🛠️ 制作工具
✍️ 作者
PaySky公司 - (https://www.paysky.io)