配置
在JMThirdPayHelper.m
頂部注益,配置支付寶碴巾、微信的key。
支付寶自定義字符串丑搔,保證唯一性即可厦瓢,建議使用bundle identity提揍。
微信是需要到微信開(kāi)發(fā)后臺(tái)申請(qǐng)的,將申請(qǐng)到的key設(shè)置到這里就好旷痕。
添加URL
info.plist中添加白名單
使用步驟
1碳锈、在AppDelegate的didFinishLaunchingWithOptions
中注冊(cè)
[[JMThirdPayHelper sharedJMThirdPayHelper] start];
2顽冶、在AppDelegate的openURL
中響應(yīng)回調(diào)
[[JMThirdPayHelper sharedJMThirdPayHelper] handleOpenURL:url];
3欺抗、支付的地方調(diào)用(調(diào)用后臺(tái)的接口獲取訂單信息)
NSMutableDictionary *params = [JMCommonMethod baseRequestParams];
[params setJsonValue:self.orderNo key:@"orderNo"];
[params setJsonValue:requestType key:@"payType"];
[[JMRequestManager sharedManager] POST:kUrlPay parameters:params completion:^(JMBaseResponse *response) {
if(response.error){
[JMProgressHelper toastInWindowWithMessage:response.errorMsg];
}else{
NSString *payInfo = response.responseObject[@"data"][@"pay_info"];
[[JMThirdPayHelper sharedJMThirdPayHelper] paymentWithData:[payInfo mj_JSONObject] type:type completionBlock:^(BOOL success) {
if(success){
[self goSuccessVC];
}else{
[self goFailVC];
}
}];
}
}];