Coder Social home page Coder Social logo

Comments (5)

fanriver avatar fanriver commented on May 24, 2024

好像是这里的代码被注释了
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,随便写个纯字母的字符串就可以了

from react-native-alipay.

jimmywong123 avatar jimmywong123 commented on May 24, 2024

好像是这里的代码被注释了
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 这个是什么原因,可以修复一下吗

from react-native-alipay.

wulaizi avatar wulaizi commented on May 24, 2024

没回调的问题已经解决
解决方法:
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

  • (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];

    }

}

from react-native-alipay.

jimmywong123 avatar jimmywong123 commented on May 24, 2024

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

from react-native-alipay.

cnpmge avatar cnpmge commented on May 24, 2024

@uiw/react-native-alipay

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

from react-native-alipay.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.