PayTabs iOS SDK
获取更多信息,请参阅 网站。
安装
CocoaPods
只需将以下行添加到你的 Podfile
pod 'PayTabs', '~> 4.3.2'
手动
下载 SDK 和 资源包,然后阅读文档了解如何将应用程序与库集成 文档
静态框架至少需要部署目标 9.0。
您必须在 Podfile
中包括以下依赖项
pod 'BIObjCHelpers'
pod 'AFNetworking', '~> 4.0.1'
pod 'Mantle'
pod 'Reachability'
pod 'Lockbox'
pod 'SBJson'
pod 'PINCache'
pod 'CardIO'
pod 'MBProgressHUD', '~> 1.1.0'
pod 'ActionSheetPicker-3.0'
当您在启用“ENABLE_BITCODE”标志的情况下手动安装SDK时可能会遇到问题,您需要将以下脚本添加到您的Podfile
中。
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['BITCODE_GENERATION_MODE'] = 'bitcode'
config.build_settings['ENABLE_BITCODE'] = 'YES'
end
end
end
使用方法
使用PayTabs支付
- 要跳过运货信息,请使用以下方法。
let bundle = Bundle(url: Bundle.main.url(forResource: "Resources", withExtension: "bundle")!)
self.initialSetupViewController = PTFWInitialSetupViewController.init(
bundle: bundle,
andWithViewFrame: self.view.frame,
andWithAmount: 5.0,
andWithCustomerTitle: "PayTabs Sample App",
andWithCurrencyCode: "USD",
andWithTaxAmount: 0.0,
andWithSDKLanguage: "en",
andWithBillingAddress: "Dubai",
andWithBillingCity: "Dubai",
andWithBillingCountry: "ARE",
andWithBillingState: "Dubai",
andWithBillingZIPCode: "12345",
andWithOrderID: "12345",
andWithPhoneNumber: "009730000000",
andWithCustomerEmail: "[email protected]",
andIsTokenization:true,
andIsPreAuth: false,
andWithMerchantEmail: "[email protected]",
andWithMerchantSecretKey: "kuTEjyEMhpVSWTwXBSOSeiiDAeMCOdyeuFZKiXAlhzjSKqswUWAgbCaYFivjvYzCWaWJbRszhjZuEQqsUycVzLddSyMIaZiQLlRqlp",
andWithMerchantRegion: "emirates", //egypt, saudi, oman, jordan
andWithAssigneeCode: "SDK",
andWithThemeColor:UIColor.red,
andIsThemeColorLight: false)
- 要传递账单和运货信息,请使用以下方法。
let bundle = Bundle(url: Bundle.main.url(forResource: "Resources", withExtension: "bundle")!)
self.initialSetupViewController = PTFWInitialSetupViewController.init(
bundle: bundle,
andWithViewFrame: self.view.frame,
andWithAmount: 5.0,
andWithCustomerTitle: "PayTabs Sample App",
andWithCurrencyCode: "USD",
andWithTaxAmount: 0.0,
andWithSDKLanguage: "en",
andWithShippingAddress: "Dubai",
andWithShippingCity: "Dubai",
andWithShippingCountry: "ARE",
andWithShippingState: "Dubai",
andWithShippingZIPCode: "123456",
andWithBillingAddress: "Dubai",
andWithBillingCity: "Dubai",
andWithBillingCountry: "ARE",
andWithBillingState: "Dubai",
andWithBillingZIPCode: "12345",
andWithOrderID: "12345",
andWithPhoneNumber: "009730000000",
andWithCustomerEmail: "[email protected]",
andIsTokenization:true,
andIsPreAuth: false,
andWithMerchantEmail: "[email protected]",
andWithMerchantSecretKey: "kuTEjyEMhpVSWTwXBSOSeiiDAeMCOdyeuFZKiXAlhzjSKqswUWAgbCaYFivjvYzCWaWJbRszhjZuEQqsUycVzLddSyMIaZiQLlRqlp",
andWithMerchantRegion: "emirates", //egypt, saudi, oman, jordan
andWithAssigneeCode: "SDK",
andWithThemeColor:UIColor.red,
andIsThemeColorLight: false)
使用Apple Pay支付
Apple Pay指南
SDK本身不添加Apple Pay按钮,请使用PKPaymentButton,并在用户点击按钮时调用我们的API。您需要根据Apple人机界面指南添加按钮。
配置Apple Pay
在开始配置之前,请检查Apple Pay要求。
在XCode中启用Apple Pay
-
在主窗口的项目导航器中,选择项目(与您的应用程序同名根组的根组)。
-
选择右侧出现的项目编辑器中的目标。
-
从项目/目标弹出菜单或大纲视图的“目标”部分中选择应用程序的目标。
-
然后单击项目编辑器中的签名与能力选项卡。
-
单击(+ 能力)以打开能力库,然后双击使用Apple登录。
支付处理证书
- 通过PT2商家控制台/证书管理生成CSR,并在Apple Pay开发者门户上下载生成的CSR。
- 从Apple Pay开发者门户下载证书,并通过PT2商家控制台/证书管理上传它,输入商家标识符。
Apple Pay测试
有关如何创建Apple Pay沙盒测试者以及如何使用测试卡的信息,请访问此链接https://developer.apple.com/apple-pay/sandbox-testing/
现在,您已准备好开始使用Apple Pay进行支付
使用参数 &ForceShippingInfo 来设置送货信息是必填还是可选。
let bundle = Bundle(url: Bundle.main.url(forResource: "Resources", withExtension: "bundle")!)
self.initialSetupViewController = PTFWInitialSetupViewController.init(applePayWith: bundle,
andWithViewFrame: view.frame,
andWithAmount: 1.0,
andWithCustomerTitle: "Pay With Apple Pay",
andWithCurrencyCode: "AED",
andWithCountryCode: "AE",
andForceShippingInfo: false,
andWithSDKLanguage: "en",
andWithOrderID: "123456",
andIsTokenization: true,
andIsPreAuth: false,
andWithMerchantEmail: "[email protected]",
andWithMerchantSecretKey: "kuTEjyEMhpVSWTwXBSOSeiiDAeMCOdyeuFZKiXAlhzjSKqswUWAgbCaYFivjvYzCWaWJbRszhjZddQqsUycVzLSyMIaZiQLlRqlp",
andWithMerchantApplePayIdentifier: "merchant.bundleid",
andWithSupportedNetworks: [.visa, .masterCard, .amex, .mada],
andWithMerchantRegion: "emirates", //egypt, saudi, oman, jordan
andWithAssigneeCode: "SDK")
支付回调
self.initialSetupViewController.didReceiveBackButtonCallback = {
}
self.initialSetupViewController.didStartPreparePaymentPage = {
// Start Prepare Payment Page
// Show loading indicator
}
self.initialSetupViewController.didFinishPreparePaymentPage = {
// Finish Prepare Payment Page
// Stop loading indicator
}
self.initialSetupViewController.didReceiveFinishTransactionCallback = {(responseCode, result, transactionID, tokenizedCustomerEmail, tokenizedCustomerPassword, token, transactionState, statementReference, traceCode) in
print("Response Code: \(responseCode)")
print("Response Result: \(result)")
print("Statement Reference: \(statementReference)");
print("Trace Code: \(traceCode)");
// In Case you are using tokenization
print("Tokenization Cutomer Email: \(tokenizedCustomerEmail)");
print("Tokenization Customer Password: \(tokenizedCustomerPassword)");
print("Tokenization Token: \(token)");
}
self.view.addSubview(initialSetupViewController.view)
self.addChild(initialSetupViewController)
initialSetupViewController.didMove(toParent: self)
支持的商户区域
根据支持的区域,将以下列表中的一个值作为参数传递 pt_merchant_region
。
- 阿联酋 =
emirates
- 埃及 =
egypt
- 沙特阿拉伯 =
saudi
- 阿曼 =
oman
- 约旦 =
jordan
- 全球 =
global
- 演示 =
demo
演示应用
查看我们的完整示例 sample。