Open wulaizi opened 4 years ago
好像是这里的代码被注释了 iOS/RCTAlipay.m
RCT_EXPORT_METHOD(payInterceptorWithUrl:(NSString *)urlStr
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) {
[AlipaySDK.defaultService payInterceptorWithUrl:urlStr fromScheme:self.appScheme callback:^(NSDictionary *resultDic) {
resolve(resultDic); // 这里的注释去除
}];
}
另外URL types alipay对应的那一项要写URL Scheme,随便写个纯字母的字符串就可以了
好像是这里的代码被注释了 iOS/RCTAlipay.m
RCT_EXPORT_METHOD(payInterceptorWithUrl:(NSString *)urlStr resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { [AlipaySDK.defaultService payInterceptorWithUrl:urlStr fromScheme:self.appScheme callback:^(NSDictionary *resultDic) { resolve(resultDic); // 这里的注释去除 }]; }
@0x5e 这个是什么原因,可以修复一下吗
没回调的问题已经解决 解决方法: AlipayModule.m
@implementation AlipayMoudle
RCT_EXPORT_METHOD(pay:(NSString *)orderInfo resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject){
NSString *appScheme = @"alipay2019082766518009";
dispatch_async(dispatch_get_main_queue(), ^{
[[AlipaySDK defaultService] payOrder:orderInfo fromScheme:appScheme callback:^(NSDictionary *resultDic) {
resolve(resultDic);
}];
});
}
RCT_EXPORT_MODULE(Alipay); @end
在AppDelegate.m
(BOOL)application:(UIApplication )application openURL:(NSURL )url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
if ([url.host isEqualToString:@"safepay"]) { //跳转支付宝钱包进行支付,处理支付结果 [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:nil]; return YES; }else{ return [RCTLinkingManager application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; }
}
// NOTE: 9.0以后使用新API接口
(BOOL)application:(UIApplication )app openURL:(NSURL )url options:(NSDictionary<NSString, id> )options { if ([url.host isEqualToString:@"safepay"]) { //跳转支付宝钱包进行支付,处理支付结果
[[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:nil];
return YES; }else{ return [RCTLinkingManager application:app openURL:url options:options];
}
}
推荐使用@uiw/react-native-alipay吧,文档清晰,配置少,很好用的插件。
@uiw/react-native-alipay
大佬,我的RN是0.57.6版本,可以用这个插件吗?
按照文档走的 也配置了URL types Identifier 写的alipay 可是app没返回 支付成功没有回调