RM SDK for iOS
示例
要运行示例项目,请先克隆仓库,然后从 Example 目录运行 pod install
。
要求
安装
RevenueMonster 可通过 CocoaPods 使用。要安装它,只需将以下行添加到 Podfile。
pod 'RevenueMonster', '1.3'
作者
Mohamed Yussuf,[email protected]
许可
Checkout示例代码
do {
try Checkout(viewController: self)
.setEnv(<<Environment Parameter>>) // set environment
.setWeChatAppID(wechatAppID: "<<WeChat Open Platform AppID>>", universalLink: "<<Universal Link>>")
.setCardInfo(name: "", cardNo: "", cvcNo: "", expMonth: 1, expYear: 2020, countryCode: "MY", isSave: true) // only use for new card
.setToken(token: "<<Card Token>>",cvcNo: "<<Cvc No>>"). // only use if use existing card token
.setBankCode("<<Set Bank Code>>"). // only use for fpx, get the bank code from open api
.pay(method: <<Method Parameter>>, checkoutId: "<<Get Checkout Id from API>>", result: Result())
} catch {
print("error: \(error.localizedDescription).")
}
// Callback Result
class Result: PaymentResult {
func onPaymentSuccess(transaction: Transaction) {
print("SUCCESS", transaction.getStatus())
}
func onPaymentFailed(error: PaymentError) {
print("FAILED", error.getCode())
}
func onPaymentCancelled() {
print("CANCELLED", "User cancelled payment");
}
}
环境参数
- 沙盒
- 生产
### 方法参数 - WECHATPAY_MY - TNG_MY - BOOST_MY - ALIPAY_CN - GRABPAY_MY - MCASH_MY - RAZERPAY_MY - PRESTO_MY - GOBIZ_MY - FPX_MY
weixin
、weixinULAPI
、alipay
、boostapp
在“信息”标签页的“URL类型”中注册 - 前往你的
Info.plist
- 将
weixin
、weixinULAPI
、alipay
、boostapp
添加到LSApplicationQueriesSchemes
微信内购支付
1. 在微信开放平台创建开发者账号
- 前往 https://open.weixin.qq.com/ 并且点击登录。
- 导航到管理中心 > 移动应用 > 创建移动应用,并输入名称、简短介绍、官方网站、包标识和通用链接。
weixin
,weixinULAPI
2. 在“信息”标签页的“URL类型”中注册 - 前往你的
Info.plist
- 将
weixin
、weixinULAPI
、alipay
、boostapp
添加到LSApplicationQueriesSchemes
3. 将您的微信 App ID 添加到 URL Scheme
- 前往
目标 > 信息 > URL类型 > URL Scheme
。 - 添加一个新的
URL Scheme
- 对于标识符设置
weixin
- 对于 URL Schemes 设置您的 App ID。
- 对于标识符设置
4. 触发支付时传递 app id 和通用链接
do {
try Checkout(viewController: self)
.setEnv(<<Environment Parameter>>) // set environment
.setWeChatAppID(wechatAppID: "<<WeChat Open Platform AppID>>", universalLink: "<<Universal Link>>")
.pay(method: <<Method Parameter>>, checkoutId: "<<Get Checkout Id from API>>", result: Result())
} catch {
print("error: \(error.localizedDescription).")
}