0x5e / react-native-alipay

Alipay SDK for React Native. Support RN >= 0.47.
MIT License
198 stars 86 forks source link

IOS没回调且不返回App #71

Open wulaizi opened 4 years ago

wulaizi commented 4 years ago

按照文档走的 也配置了URL types Identifier 写的alipay 可是app没返回 支付成功没有回调

fanriver commented 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,随便写个纯字母的字符串就可以了

jimmywong123 commented 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);    // 这里的注释去除
    }];
}

@0x5e 这个是什么原因,可以修复一下吗

wulaizi commented 4 years ago

没回调的问题已经解决 解决方法: AlipayModule.m

import "AlipayModule.h"

import <AlipaySDK/AlipaySDK.h>

@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

}

// NOTE: 9.0以后使用新API接口

}

jimmywong123 commented 4 years ago

推荐使用@uiw/react-native-alipay吧,文档清晰,配置少,很好用的插件。

cnpmge commented 4 years ago

@uiw/react-native-alipay

大佬,我的RN是0.57.6版本,可以用这个插件吗?