npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-sf-ali-pay

v1.0.61

Published

支付宝支付

Downloads

21

Readme

react-native-sf-Ali-pay

安装

  • npm i react-native-sf-ali-pay
  • react-native link react-native-sf-ali-pay

IOS 端配置

URL Schemes

  • 配置白名单 URL Schemes (例如:RNGZFB):

支付宝SDK依赖的库

  • https://img.alicdn.com/top/i1/LB1PlBHKpXXXXXoXXXXXXXXXXXX
  • 以下文件需要手动添加到项目工程内(已存在则不需要手动添加):
  • node_modules/react-native-sf-ali-pay/ios/SDK/AlipaySDK.bundle
  • node_modules/react-native-sf-ali-pay/ios/SDK/AlipaySDK.framework (此文件也会自动添加到Link Binary With Libraries里)
  • Build Phases 添加支付宝SDK node_modules/react-native-sf-ali-pay/ios/SDK/AlipaySDK
  • 在Build Settings中的Framework Search Paths中,增加:
  • $(SRCROOT)/../node_modules/react-native-sf-ali-pay/ios/SDK

Android 端

  • 1.0 .将alipaySdk-xxxxxxxx.jar包放入商户应用工程的libs目录下
  • 1.1 进入商户应用工程的“Project Structure”,在app module下选择“File dependency”,将libs目录下的alipaySDK-xxxxxxxx.jar导入
  • 1.2 或者在app module下的build.gradle下手动添加依赖,如下代码所示:
dependencies {
......
compile files('libs/alipaySdk-20170725.jar')
......
}
  • 2.0 修改Manifest
  • 2.1 在商户应用工程的AndroidManifest.xml文件里面添加声明:
<!--权限-->
<activity
android:name="com.alipay.sdk.app.H5PayActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:exported="false"
android:screenOrientation="behind"
android:windowSoftInputMode="adjustResize|stateHidden" >
</activity>
<activity
android:name="com.alipay.sdk.app.H5AuthActivity"
android:configChanges="orientation|keyboardHidden|navigation"
android:exported="false"
android:screenOrientation="behind"
android:windowSoftInputMode="adjustResize|stateHidden" >
</activity>
  • 2.11和权限声明
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  • 3.0 添加混淆规则
  • 3.01 在商户应用工程的proguard-project.txt里添加以下相关规则:
-keep class com.alipay.android.app.IAlixPay{*;}
-keep class com.alipay.android.app.IAlixPay$Stub{*;}
-keep class com.alipay.android.app.IRemoteServiceCallback{*;}
-keep class com.alipay.android.app.IRemoteServiceCallback$Stub{*;}
-keep class com.alipay.sdk.app.PayTask{ public *;}
-keep class com.alipay.sdk.app.AuthTask{ public *;}
-keep class com.alipay.sdk.app.H5PayCallback {
<fields>;
<methods>;
}
-keep class com.alipay.android.phone.mrpc.core.** { *; }
-keep class com.alipay.apmobilesecuritysdk.** { *; }
-keep class com.alipay.mobile.framework.service.annotation.** { *; }
-keep class com.alipay.mobilesecuritysdk.face.** { *; }
-keep class com.alipay.tscenter.biz.rpc.** { *; }
-keep class org.json.alipay.** { *; }
-keep class com.alipay.tscenter.** { *; }
-keep class com.ta.utdid2.** { *;}
-keep class com.ut.device.** { *;}

IOS Appdelegate 添加监听

// 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:^(NSDictionary *resultDic) {
//
NSDictionary * dic = [[NSDictionary alloc]initWithObjectsAndKeys:[NSString stringWithFormat:@"%d",[[resultDic objectForKey:@"resultStatus"] intValue]],@"respCode",nil];
NSNotification *notification = [NSNotification notificationWithName:@"PAY_AlIPAY" object:nil userInfo:dic];
[[NSNotificationCenter defaultCenter] postNotification:notification];

}];
}
return YES;
}


- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if ([url.host isEqualToString:@"safepay"]) {
// 支付跳转支付宝钱包进行支付,处理支付结果
[[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
NSDictionary * dic = [[NSDictionary alloc]initWithObjectsAndKeys:[NSString stringWithFormat:@"%d",[[resultDic objectForKey:@"resultStatus"] intValue]],@"respCode",nil];
NSNotification *notification = [NSNotification notificationWithName:@"PAY_AlIPAY" object:nil userInfo:dic];
[[NSNotificationCenter defaultCenter] postNotification:notification];

}];

}
return YES;
}

react 添加监听方法

import { NativeAppEventEmitter } from 'react-native';
NativeAppEventEmitter.addListener(
'AliResp',
(content) => {
//数据内容
}
}
);
this.listener && this.listener.remove();

回调中errCode值列表:
errCode     errMessage
名称       描述
9000       成功
6001       中途退出
6002       网络连接错误
4000       支付订单失败

Methods

| Methods | Params | Param Types | description | Example | |:-----|:-----|:-----|:-----|:-----| |registerApp|string|string|支付宝IOS白名单|SFAlipay.registerApp('IOS白名单标识')| |Pay|string|string|需要传递的参数|SFAlipay.Pay('服务端获取支付字符串',()=>{'支付成功回调'})|