PaySky Button SDK
SDK 的目的是帮助程序员使用为 IOS 定制的 PaySky 支付 SDK。
入门指南
以下说明将帮助您将项目复制到本地机器上,以便进行开发和测试。
先决条件
你需要安装哪些软件以及如何安装它们
1-COCOPODS installed on your machine .
2-Xcode
3-Create new IOS project in xcode to use SDK or if you have created a project before with swit
安装
一步步指导您如何将我们的 SDK 添加到您的项目中。
1- open your xcode project.
2- in your project in Podfile in project level add :-
pod 'PayButton'
3- open your terminal in project path and write this command:-
(for first try)
- pod deintegrate
- pod update
(for second try)
- pod install
### Using SDK
为了使用我们的 SDK,您应该从我们公司获取商户 ID 和终端 ID。
1-导入 PayButton 2 - 从 PayButton 创建一个新实例:
let paymentViewController = PaymentViewController ()
您需要向 PayButton 类实例传递一些参数:1-商户 ID。2-终端 ID。3-付款金额。4-货币代码 [可选]。5-商户安全哈希。6-交易参考号。
注意:如果您想将安全哈希、商户 ID 和终端 ID 保存到存储之前进行加密。
示例:
paymentViewController.amount = "amount" // Amount
paymentViewController.delegate = self // PaymentDelegate
paymentViewController.mId = "merchantId" // Merchant id
paymentViewController.tId = "terminalId" // Terminal id
paymentViewController.Currency = "currencyCode" // Currency Code [Optional]
paymentViewController.refnumber = "reference number"" // unique transaction reference number.
paymentViewController.Key = "Merchant secure hash" // merchant secrue hash
paymentViewController.pushViewController()
2 - 为了创建回调,调用支付委托中的交易:
implete deleget on your ViewController
class ViewController: UIViewController, PaymentDelegate {\
var receipt: TransactionStatusResponse = TransactionStatusResponse()
func finishSdkPayment(_ receipt: TransactionStatusResponse) {
self.receipt = receipt
if receipt.Success {
LabeResoinse.setTitle("Transaction completed successfully, click here to show callback result", for: .normal)
}else {
LabeResoinse.setTitle("Transaction has been failed click to callback callback ", for: .normal)
}
}
}
在SDK中创建交易,您只需调用createTransaction方法,并将PaymentTransactionCallback监听器传递给它以在交易完成后调用。该监听器有2个方法:
1 - finishSdkPayment方法该方法在通过卡片支付交易成功时由SuccessfulCardTransaction对象调用。从创建交易监听器中获取的SuccessfulCardTransaction对象包含:NetworkReference变量,即交易的参考编号。AuthCode变量、ActionCode变量、ReceiptNumber变量、amount变量。
2 - finishSdkPayment方法该方法在客户使用钱包交易时由SuccessfulWalletTransaction对象调用。从创建交易监听器中获取的SuccessfulWalletTransaction对象包含:NetworkReference变量,即交易的参考编号、amount变量。
示例:
func finishSdkPayment(_ receipt: TransactionStatusResponse) {
if receipt.Success // will be true if transaction success
{
print(receipt.NetworkReference)
}else{
print(receipt.Message) // resonse of error
}
}
## Deployment
1-Before deploy your project live ,you should get a merchant id and terminal id from our company .
2-you should keep your merchant id and terminal id secured
in your project, encrypt them before save them in project.
## Built With
* [Alamofire](https://github.com/Alamofire/Alamofire)
* [EVReflection](https://github.com/evermeer/EVReflection)
## Authors
**PaySky Company** - (https://www.paysky.io)
## Sample Project
**https://github.com/payskyCompany/payButtonIOS.git**