Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
004af0975b | ||
![]() |
cf0ca78dc7 | ||
![]() |
175f295f8f | ||
![]() |
ddae4e78c1 | ||
![]() |
c16c1be2c0 |
63
.npmignore
Normal file
63
.npmignore
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# JS
|
||||||
|
node_modules
|
||||||
|
yarn.lock
|
||||||
|
|
||||||
|
# Config files
|
||||||
|
renovate.json
|
||||||
|
|
||||||
|
# Example
|
||||||
|
example/
|
||||||
|
|
||||||
|
# Android
|
||||||
|
android/*/build/
|
||||||
|
android/gradlew
|
||||||
|
android/build
|
||||||
|
android/gradlew.bat
|
||||||
|
android/gradle/
|
||||||
|
android/com_crashlytics_export_strings.xml
|
||||||
|
android/local.properties
|
||||||
|
android/.gradle/
|
||||||
|
android/.signing/
|
||||||
|
android/.idea/gradle.xml
|
||||||
|
android/.idea/libraries/
|
||||||
|
android/.idea/workspace.xml
|
||||||
|
android/.idea/tasks.xml
|
||||||
|
android/.idea/.name
|
||||||
|
android/.idea/compiler.xml
|
||||||
|
android/.idea/copyright/profiles_settings.xml
|
||||||
|
android/.idea/encodings.xml
|
||||||
|
android/.idea/misc.xml
|
||||||
|
android/.idea/modules.xml
|
||||||
|
android/.idea/scopes/scope_settings.xml
|
||||||
|
android/.idea/vcs.xml
|
||||||
|
android/*.iml
|
||||||
|
android/.settings
|
||||||
|
|
||||||
|
# iOS
|
||||||
|
ios/*.xcodeproj/xcuserdata
|
||||||
|
*.pbxuser
|
||||||
|
*.mode1v3
|
||||||
|
*.mode2v3
|
||||||
|
*.perspectivev3
|
||||||
|
*.xcuserstate
|
||||||
|
project.xcworkspace/
|
||||||
|
xcuserdata/
|
||||||
|
ios/build/
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
.DS_Store
|
||||||
|
.DS_Store?
|
||||||
|
coverage.android.json
|
||||||
|
coverage.ios.json
|
||||||
|
npm-debug.log
|
||||||
|
.github
|
||||||
|
._*
|
||||||
|
.Spotlight-V100
|
||||||
|
.Trashes
|
||||||
|
ehthumbs.db
|
||||||
|
Thumbs.dbandroid/gradle
|
||||||
|
docs
|
||||||
|
.idea
|
||||||
|
bin/test.js
|
||||||
|
codorials
|
||||||
|
website/
|
15
README.md
15
README.md
@@ -1,6 +1,8 @@
|
|||||||
react-native-uiwjs-alipay
|
react-native-uiwjs-alipay
|
||||||
===
|
===
|
||||||
|
|
||||||
|
[](https://npmjs.org/package/jaywcjlove/react-native-uiwjs-alipay)
|
||||||
|
|
||||||
基于 React Native 的宝支付插件。适用于商家在 App 应用中集成支付宝支付功能,商家 APP 调用支付宝提供的 SDK,SDK 再调用支付宝 APP 内的支付模块。如果用户已安装支付宝APP,商家APP会跳转到支付宝中完成支付,支付完后跳回到商家 APP 内,最后展示支付结果。如果用户没有安装支付宝 APP,商家 APP 内会调起支付宝网页支付收银台,用户登录支付宝账户,支付完后展示支付结果。完整实例 [Example](./example)
|
基于 React Native 的宝支付插件。适用于商家在 App 应用中集成支付宝支付功能,商家 APP 调用支付宝提供的 SDK,SDK 再调用支付宝 APP 内的支付模块。如果用户已安装支付宝APP,商家APP会跳转到支付宝中完成支付,支付完后跳回到商家 APP 内,最后展示支付结果。如果用户没有安装支付宝 APP,商家 APP 内会调起支付宝网页支付收银台,用户登录支付宝账户,支付完后展示支付结果。完整实例 [Example](./example)
|
||||||
|
|
||||||

|

|
||||||
@@ -113,6 +115,19 @@ async function authInfo() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `Alipay.getVersion` 获取 SDK 版本
|
||||||
|
|
||||||
|
> `Alipay.getVersion: () => Promise<string>;`
|
||||||
|
|
||||||
|
```js
|
||||||
|
import Alipay from 'react-native-uiwjs-alipay';
|
||||||
|
|
||||||
|
async function getVersion() {
|
||||||
|
const version = await Alipay.getVersion();
|
||||||
|
console.log('version:', version);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## 支付宝返回应用 iOS 设置
|
## 支付宝返回应用 iOS 设置
|
||||||
|
|
||||||
- ⚠️ Android 端不需要做任何设置。
|
- ⚠️ Android 端不需要做任何设置。
|
||||||
|
@@ -71,6 +71,12 @@ public class AlipayModule extends ReactContextBaseJavaModule {
|
|||||||
payThread.start();
|
payThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ReactMethod
|
||||||
|
public void getVersion(Promise promise) {
|
||||||
|
PayTask payTask = new PayTask(getCurrentActivity());
|
||||||
|
promise.resolve(payTask.getVersion());
|
||||||
|
}
|
||||||
|
|
||||||
private WritableMap getWritableMap(Map<String, String> map) {
|
private WritableMap getWritableMap(Map<String, String> map) {
|
||||||
WritableMap writableMap = Arguments.createMap();
|
WritableMap writableMap = Arguments.createMap();
|
||||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||||
|
@@ -3,6 +3,12 @@ import { Button, StyleSheet, Text, View, Linking, AppState } from 'react-native'
|
|||||||
import Alipay from 'react-native-uiwjs-alipay';
|
import Alipay from 'react-native-uiwjs-alipay';
|
||||||
|
|
||||||
export default class App extends Component {
|
export default class App extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
version: '',
|
||||||
|
}
|
||||||
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
Alipay.setAlipayScheme('uiwjspay');
|
Alipay.setAlipayScheme('uiwjspay');
|
||||||
}
|
}
|
||||||
@@ -18,6 +24,11 @@ export default class App extends Component {
|
|||||||
// resule => success=true&auth_code=9c11732de44f4f1790b63978b6fbOX53&result_code=200&alipay_open_id=20881001757376426161095132517425&user_id=2088003646494707
|
// resule => success=true&auth_code=9c11732de44f4f1790b63978b6fbOX53&result_code=200&alipay_open_id=20881001757376426161095132517425&user_id=2088003646494707
|
||||||
console.log('authInfo:resule-->>>', resule);
|
console.log('authInfo:resule-->>>', resule);
|
||||||
}
|
}
|
||||||
|
getVersion = async () => {
|
||||||
|
const version = await Alipay.getVersion();
|
||||||
|
this.setState({ version });
|
||||||
|
console.log('version:', version);
|
||||||
|
}
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
@@ -34,6 +45,12 @@ export default class App extends Component {
|
|||||||
color="#841584"
|
color="#841584"
|
||||||
accessibilityLabel="Learn more about this purple button"
|
accessibilityLabel="Learn more about this purple button"
|
||||||
/>
|
/>
|
||||||
|
<Button
|
||||||
|
onPress={this.getVersion}
|
||||||
|
title="获取 SDK 版本"
|
||||||
|
color="#841584"
|
||||||
|
/>
|
||||||
|
<Text>{this.state.version}</Text>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
5
index.d.ts
vendored
5
index.d.ts
vendored
@@ -126,6 +126,11 @@ export const Alipay: {
|
|||||||
* @returns result 支付宝回调结果 https://opendocs.alipay.com/open/218/105327
|
* @returns result 支付宝回调结果 https://opendocs.alipay.com/open/218/105327
|
||||||
*/
|
*/
|
||||||
authInfo: (authInfoStr: string) => Promise<AuthResult>;
|
authInfo: (authInfoStr: string) => Promise<AuthResult>;
|
||||||
|
/**
|
||||||
|
* 获取当前 SDK 版本号
|
||||||
|
* @return 当前 SDK 版本字符串
|
||||||
|
*/
|
||||||
|
getVersion: () => Promise<string>;
|
||||||
/**
|
/**
|
||||||
* 设置支付宝跳转Scheme,仅 iOS
|
* 设置支付宝跳转Scheme,仅 iOS
|
||||||
* @param scheme scheme = `ap` + `APPID`
|
* @param scheme scheme = `ap` + `APPID`
|
||||||
|
23
index.js
23
index.js
@@ -1,23 +1,30 @@
|
|||||||
import { NativeModules, Platform } from 'react-native';
|
import { NativeModules, Platform } from 'react-native';
|
||||||
|
|
||||||
export default class Alipay {
|
export default class Alipay {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝端支付
|
* 支付
|
||||||
* @param orderInfo 支付详情
|
* @param orderInfo 支付详情
|
||||||
* @param callback 支付宝回调结果 详情见 https://docs.open.alipay.com/204/105301
|
* @returns result 支付宝回调结果 https://docs.open.alipay.com/204/105301
|
||||||
*/
|
*/
|
||||||
static alipay(orderInfo) {
|
static alipay(orderInfo) {
|
||||||
return NativeModules.Alipay.alipay(orderInfo);
|
return NativeModules.Alipay.alipay(orderInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝授权请求信息
|
* 快速登录授权
|
||||||
* @param infoStr 授权请求信息字串
|
* @param authInfoStr 验证详情
|
||||||
* @param callback 授权结果回调 详情见 https://opendocs.alipay.com/open/218/105325
|
* @returns result 支付宝回调结果 详情见 https://opendocs.alipay.com/open/218/105325
|
||||||
*/
|
*/
|
||||||
static authInfo(infoStr) {
|
static authInfo(authInfoStr) {
|
||||||
return NativeModules.Alipay.authInfo(infoStr)
|
return NativeModules.Alipay.authInfo(authInfoStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前版本号
|
||||||
|
* @return 当前版本字符串
|
||||||
|
*/
|
||||||
|
static getVersion() {
|
||||||
|
return NativeModules.Alipay.getVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -20,6 +20,10 @@ RCT_EXPORT_MODULE()
|
|||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:@"RCTOpenURLNotification" object:nil];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:@"RCTOpenURLNotification" object:nil];
|
||||||
|
// 反注释下面代码,可以输出支付宝 SDK 调试信息,便于诊断问题
|
||||||
|
// [AlipaySDK startLogWithBlock:^(NSString* log){
|
||||||
|
// NSLog(@"%@", log);
|
||||||
|
// }];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@@ -97,6 +101,10 @@ RCT_EXPORT_METHOD(authInfo:(NSString *)info resolver:(RCTPromiseResolveBlock)res
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RCT_EXPORT_METHOD(getVersion: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
||||||
|
resolve([[AlipaySDK defaultService] currentVersion]);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* [warn][tid:main][RCTModuleData.mm:68] Module Alipay requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`.
|
* [warn][tid:main][RCTModuleData.mm:68] Module Alipay requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`.
|
||||||
* In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
|
* In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-uiwjs-alipay",
|
"name": "react-native-uiwjs-alipay",
|
||||||
"version": "1.4.0",
|
"version": "1.5.1",
|
||||||
"description": "基于 React Native 的宝支付插件",
|
"description": "基于 React Native 的宝支付插件",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
Reference in New Issue
Block a user