simpl-oneclick-ios-sdk
如何安装
CocoaPods
CocoaPods 是 Cocoa 项目的依赖项管理器。您可以使用以下命令安装它
$ gem install cocoapods
要使用 CocoaPods 将 GetSimpl 添加到您的 Xcode 项目中,在 Podfile 中指定它
pod 'SimplOneClick'
然后,运行以下命令
$ pod install
集成
- 将以下内容添加到您的Info.plist文件中
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>smpYourMerchantID</string>
</array>
</dict>
</array>
请注意,您必须在smpYourMerchantID
中添加您的商户ID,例如smp55d72761ec60ytbnk97414182
。
- 对于iOS 9及更高版本,还必须在您的Info.plist文件中添加以下内容
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>getsimpl.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>simplApp</string>
</array>
初始化
-
导入库
import SimplOneClick
-
使用您的商户ID初始化SDK,通常在应用程序的didFinishLaunchingWithOptions方法中
GSManager.initialize(withMerchantID: "Your merchant id")
-
要在沙盒模式下运行Simpl
GSManager.enableSandBoxEnvironment(true)
Simpl支付选项的实现
-
检查用户是否已预批准
let user = GSUser(phoneNumber: phone , email: email ) GSManager.shared().checkApproval(for: user) { (approved, firstTransaction, text, error) in }
approved : If GSUser is pre-approved or not isFirstTransactionOfUser : If user has already done transactions previously or not buttonText : The text to display on Simpl button. If GSUser is pre-approved,this will contain a value specific to merchant with default value of "Buy Now, Pay Later". Will be nil if GSUser is not pre-approved. error : Error if any
如果用户已批准,则向用户展示Simpl按钮。
-
要展示Simpl选项,商家可以使用自己的自定义按钮。但是他们应该使用上述批准调用中的
buttonText
值来显示按钮上的文本。