1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

Compare commits

...

21 Commits

Author SHA1 Message Date
jaywcjlove
28c864562e released v2.0.6 2020-07-14 18:22:02 +08:00
jaywcjlove
fbe1d4d29b Update README.md 2020-07-14 18:21:37 +08:00
jaywcjlove
74140a294e chore: ios/react-native-alipay.podspec -> ios/Alipay.podspec 2020-07-14 18:15:45 +08:00
jaywcjlove
3ce5bbf8c5 released v2.0.2 2020-07-14 17:36:47 +08:00
jaywcjlove
134155dfd6 Update README.md 2020-07-14 17:35:54 +08:00
jaywcjlove
4cbcf61e0b released v2.0.1 2020-07-14 16:44:20 +08:00
jaywcjlove
8e6367223c chore: Rename the package name: @uiw/react-native-alipay 2020-07-14 16:35:20 +08:00
jaywcjlove
53e2da68ae released v2.0.0 2020-07-14 16:29:43 +08:00
jaywcjlove
c3df987be6 Update README.md 2020-07-14 16:29:10 +08:00
jaywcjlove
fea05f55f8 chore: Rename the package name react-native-uiwjs-alipay => @uiwjs/react-native-alipay 2020-07-14 16:24:20 +08:00
jaywcjlove
0c22861396 Update README.md 2020-07-14 15:53:31 +08:00
jaywcjlove
004af0975b released v1.5.1 2020-07-14 15:49:49 +08:00
jaywcjlove
cf0ca78dc7 chore: Update .npmignore file. 2020-07-14 15:49:30 +08:00
jaywcjlove
175f295f8f released v1.5.0 2020-07-14 15:47:16 +08:00
jaywcjlove
ddae4e78c1 chore: Add .npmignore file. 2020-07-14 15:46:29 +08:00
jaywcjlove
c16c1be2c0 feat: 添加获取当前 SDK 版本 API。 2020-07-14 15:39:41 +08:00
jaywcjlove
fb9a44575d released v1.4.0 2020-07-14 15:00:39 +08:00
jaywcjlove
90361afb76 Update README.md 2020-07-14 14:59:41 +08:00
jaywcjlove
05b4dc3d87 feat: 调整 API 调用方式,callback => promise 2020-07-14 14:52:13 +08:00
jaywcjlove
bbc36d501b released v1.3.1 2020-07-14 12:46:39 +08:00
jaywcjlove
7c2f89ee0b feat(Android): Add authInfo feature. 2020-07-14 12:45:50 +08:00
11 changed files with 298 additions and 148 deletions

63
.npmignore Normal file
View 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/

View File

@@ -1,12 +1,16 @@
react-native-uiwjs-alipay
@uiw/react-native-alipay
===
基于 React Native 的宝支付插件。适用于商家在 App 应用中集成支付宝支付功能,商家 APP 调用支付宝提供的 SDKSDK 再调用支付宝 APP 内的支付模块。如果用户已安装支付宝APP商家APP会跳转到支付宝中完成支付支付完后跳回到商家 APP 内,最后展示支付结果。如果用户没有安装支付宝 APP商家 APP 内会调起支付宝网页支付收银台,用户登录支付宝账户,支付完后展示支付结果。完整实例 [Example](./example)
[![NPM Version](https://img.shields.io/npm/v/@uiw/react-native-alipay.svg)](https://npmjs.org/package/@uiw/react-native-alipay)
基于 React Native 的宝支付插件,支持 iOS/Android。适用于商家在 App 应用中集成支付宝支付功能,商家 APP 调用支付宝提供的 SDKSDK 再调用支付宝 APP 内的支付模块。如果用户已安装支付宝APP商家APP会跳转到支付宝中完成支付支付完后跳回到商家 APP 内,最后展示支付结果。如果用户没有安装支付宝 APP商家 APP 内会调起支付宝网页支付收银台,用户登录支付宝账户,支付完后展示支付结果。完整实例 [Example](./example)
![](https://gw.alipayobjects.com/zos/skylark-tools/public/files/c0aa8379f5f57c55f1e5bf25e6f426d1.png)
![](https://gw.alipayobjects.com/zos/skylark-tools/public/files/2454bffde14f428b2eeb2bfb6aa28d6b.png)
## 注意事项
1. Android支持2.3及以上的系统版本运行。
2. iOSiOS 6.0以上(包含iOS 6.0)。
3. 支持手机系统iOS苹果、Android安卓
@@ -17,7 +21,7 @@ react-native-uiwjs-alipay
## 安装依赖
```bash
yarn add react-native-uiwjs-alipay
yarn add @uiw/react-native-alipay
# react-native version >= 0.60+
$ cd ios && pod install
```
@@ -26,21 +30,29 @@ $ cd ios && pod install
### `Alipay.alipay` 支付
- ⚠️ 注意支付成功返回结果是一个字符串,[返回内容](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/4c89c4e0e623e5073e4dc84a86978b1c5da18704/index.d.ts#L50-L74)
> `Alipay.alipay: (payInfo: string) => Promise<OrderResult>;`
- ⚠️ 注意支付成功返回结果是一个字符串,[返回内容](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/index.d.ts#L50-L74)
- ⚠️ 支付宝需要设置 `Scheme` 和 iOS添加原生代码才能支持支付和[回弹商家APP](#支付宝返回应用-ios-设置)的功能
- ⚠️ 支付宝 `管理中心-支付宝开放平台` 需要签约 [`APP支付`](https://opendocs.alipay.com/open/200/105310#%E6%B7%BB%E5%8A%A0%E5%BA%94%E7%94%A8%E5%8A%9F%E8%83%BD)
```javascript
import Alipay from 'react-native-uiwjs-alipay';
import Alipay from '@uiw/react-native-alipay';
// 设置 支付宝 URL Schemes要表述他是宇宙唯一性可以使用 `bundle Identifier`
// scheme = `alipay` + `APPID``APPID` 为支付宝分配给开发者的应用ID
Alipay.setAlipayScheme(scheme);
// ⚠️ 目前不可用,设置支付宝沙箱环境,仅 Android 支持
// Alipay.setAlipaySandbox(isSandbox);
// 支付宝端支付
// payInfo 是后台拼接好的支付参数
Alipay.alipay(payInfo, (res)=> console.log(res))
async function aliPay() {
// 支付宝端支付
// payInfo 是后台拼接好的支付参数
// return_url=
const payInfo = 'alipay_sdk=alipay-sdk-java-dynamicVersionNo&app_id=2021001172656340&biz_content=%7B%22out_trade_no%22%3A%221111112222222%22%2C%22total_amount%22%3A%220.01%22%2C%22subject%22%3A%221234%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%7D&charset=UTF-8&format=json&method=alipay.trade.app.pay&notify_url=http%3A%2F%2Fane.boshu.ltd%2Fowner%2Fpay%2Fapi%2FownerPay%2Fcallback&sign=oUQmGtkv8mrhJ0YwHl9%2FfxMcoLACWuSFKiMTC4Id8nc%2FZVvDQ6MLQq5hhtEN03Qn1%2BAtzTAaofE8nNixdroxOek2l5YtOAcYcXVYlJIyogN%2B22erN2NpDTWJ7tQTKgYFDJLRiG0DZJaxfADhUUF6UR9kdA8omoXKLDlP17ZPUs5Jr4aKv5HJtH5C53ui7PbmyWYg934L4UDC2F%2F9pPQlRwwDeE1SAaV3HW9Dt83kK52o8%2FlChXdotbFdAvH0d4qYGhpEYU5sepj9xiOMyL9aC4pMXW9INYLLGbvtqtlRchZTAfH5yji6nqqQm9KKMmcVrWdBDLyjFVNpejq1UjbJBw%3D%3D&sign_type=RSA2&timestamp=2020-07-09+12%3A16%3A16&version=1.0';
const resule = await Alipay.alipay(payInfo);
console.log('alipay:resule-->>>', resule);
}
```
订单详情 [`payInfo`](https://opendocs.alipay.com/open/204/105295#%E5%BF%AB%E6%8D%B7%E8%AE%A2%E5%8D%95%E6%94%AF%E4%BB%98%20iOS) 编码前的数据
@@ -58,7 +70,7 @@ alipay_sdk=alipay-sdk-java-dynamicVersionNo&app_id=xxxxxxxxxxxxx&biz_content=%7B
- ⚠️ 后台 SDK 根据所有数据生成 `sign`,建议通过 API 拿到这个数据,拼接数据会报错。
- ⚠️ `out_trade_no` 订单 id 和 `sign` 签名 是唯一的,每次不一样,需要后台生成。
支付返回结果,支付宝[返回结果参数说明](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/4c89c4e0e623e5073e4dc84a86978b1c5da18704/index.d.ts#L50-L74)
支付返回结果,支付宝[返回结果参数说明](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/index.d.ts#L50-L74)
```json
{
@@ -70,23 +82,30 @@ alipay_sdk=alipay-sdk-java-dynamicVersionNo&app_id=xxxxxxxxxxxxx&biz_content=%7B
### `Alipay.authInfo` 登录授权
- ⚠️ 注意授权成功返回结果是一个字符串,[返回内容](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/4c89c4e0e623e5073e4dc84a86978b1c5da18704/index.d.ts#L89-L113)
> `Alipay.authInfo: (authInfoStr: string) => Promise<AuthResult>`;
- ⚠️ 注意授权成功返回结果是一个字符串,[返回内容](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/index.d.ts#L89-L113)
- ⚠️ 支付宝需要设置 `Scheme` 和 iOS添加原生代码才能支持验证[回弹商家APP](#支付宝返回应用-ios-设置)的功能
- ⚠️ 支付宝 `管理中心-支付宝开放平台` 需要签约 [`APP支付宝登录`](https://opendocs.alipay.com/open/200/105310#%E6%B7%BB%E5%8A%A0%E5%BA%94%E7%94%A8%E5%8A%9F%E8%83%BD)
```javascript
import Alipay from 'react-native-uiwjs-alipay';
import Alipay from '@uiw/react-native-alipay';
// 设置 支付宝 URL Schemes要表述他是宇宙唯一性可以使用 `bundle Identifier`
// scheme = `alipay` + `APPID``APPID` 为支付宝分配给开发者的应用ID
Alipay.setAlipayScheme(scheme);
// 支付宝端支付
// authInfoStr 是后台拼接好的验证参数
// apiname=com.alipay.account.auth&app_id=xxxxx&app_name=mc&auth_type=AUTHACCOUNT&biz_type=openservice&method=alipay.open.auth.sdk.code.get&pid=xxxxx&product_id=APP_FAST_LOGIN&scope=kuaijie&sign_type=RSA2&target_id=20141225xxxx&sign=fMcp4GtiM6rxSIeFnJCVePJKV43eXrUP86CQgiLhDHH2u%2FdN75eEvmywc2ulkm7qKRetkU9fbVZtJIqFdMJcJ9Yp%2BJI%2FF%2FpESafFR6rB2fRjiQQLGXvxmDGVMjPSxHxVtIqpZy5FDoKUSjQ2%2FILDKpu3%2F%2BtAtm2jRw1rUoMhgt0%3D
Alipay.authInfo(authInfoStr, (res)=> console.log(res))
async function authInfo() {
// 支付宝端授权验证
// authInfoStr 是后台拼接好的验证参数
const authInfoStr = 'app_name=mc&auth_type=AUTHACCOUNT&apiname=com.alipay.account.auth&biz_type=openservice&product_id=APP_FAST_LOGIN&scope=kuaijie&pid=2088421915791034&target_id=15946456110003465&app_id=2021001172656340&sign_type=RSA2&sign=keluG28qbbLwAcSDI4VmCNOGHJoF3xgpVeqXu1nCBCYo%2FlYYGe00fTfV9L4G73Sk7%2B4IwK%2BZV8IL%2F04cVtk6SR74lKAR3rYOoUdQ09ZrZFuQoUkO0vekajhp75IDQIg6PedCyY0SjFTqrHlH%2FImscBwitxrlSc9YbN7uW0gY34K8t7v8NhDoqzKJeoIz43UxF5U1DpUA1ISBVxwO7du1t6rYltsRhReayPS3hnvmwYSKQZUEgBvJ%2BT2XdyCaz%2FdGV907lYagPp1Oxkoaj%2FvW5NjNsRnid7vH944CoFj9XtBK%2FNTk2tBPTHFxYRQTEG1PkgkBohGpAWOFGGOuapH0ag%3D%3D';
const resule = await Alipay.authInfo(authInfoStr);
// resule => success=true&auth_code=9c11732de44f4f1790b63978b6fbOX53&result_code=200&alipay_open_id=20881001757376426161095132517425&user_id=2088003646494707
console.log('authInfo:resule-->>>', resule);
}
```
授权返回结果,支付宝[返回结果参数说明](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/4c89c4e0e623e5073e4dc84a86978b1c5da18704/index.d.ts#L89-L113)
授权返回结果,支付宝[返回结果参数说明](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/index.d.ts#L89-L113)
```json
{
@@ -96,25 +115,38 @@ Alipay.authInfo(authInfoStr, (res)=> console.log(res))
}
```
### `Alipay.getVersion` 获取 SDK 版本
> `Alipay.getVersion: () => Promise<string>;`
```js
import Alipay from '@uiw/react-native-alipay';
async function getVersion() {
const version = await Alipay.getVersion();
console.log('version:', version);
}
```
## 支付宝返回应用 iOS 设置
- ⚠️ Android 端不需要做任何设置。
- ⚠️ 如果用户从 `支付宝App` 跳转到 `商家APP`,是通过系统功能切换,而不是通过 `支付宝APP` 功能键返回 `商家APP`,回调函数是不起作用的,可通过 [`AppState.addEventListener`](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/5daea87bf0af05d60d0ae9e4c04e1e2d1a6e4273/example/App.js#L8-L24) 监听事件请求后台 API来优化这一用户体验。
- ⚠️ 如果用户从 `支付宝App` 跳转到 `商家APP`,是通过系统功能切换,而不是通过 `支付宝APP` 功能键返回 `商家APP`,回调函数是不起作用的,可通过 [`AppState.addEventListener`](https://github.com/uiwjs/react-native-alipay/blob/5daea87bf0af05d60d0ae9e4c04e1e2d1a6e4273/example/App.js#L8-L24) 监听事件请求后台 API来优化这一用户体验。
1. 在代码中设置支付宝 [`URL Schemes`](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/5daea87bf0af05d60d0ae9e4c04e1e2d1a6e4273/example/App.js#L7),下面实例 [`uiwjspay`](https://github.com/uiwjs/react-native-uiwjs-alipay/commit/f6d21b6b7ec7236b195c56281f971092f3c9bb08) 是定义的 `scheme`,你也可以定义为 `alipay` + `appid``appid` 为支付宝分配给开发者的应用ID用来表述 `scheme` 唯一性。
1. 在代码中设置支付宝 [`URL Schemes`](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/example/App.js#L7),下面实例 [`uiwjspay`](https://github.com/uiwjs/react-native-alipay/commit/f6d21b6b7ec7236b195c56281f971092f3c9bb08) 是定义的 `scheme`,你也可以定义为 `alipay` + `appid``appid` 为支付宝分配给开发者的应用ID用来表述 `scheme` 唯一性。
```js
Alipay.setAlipayScheme('uiwjspay');
```
2. 在请求支付的 [`payInfo`](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/1eff1dd94f3ae733db2913400e1aac382d056871/example/App.js#L27-L30) 中必须包含 [`return_url=uiwjspay://`](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/5daea87bf0af05d60d0ae9e4c04e1e2d1a6e4273/example/App.js#L27-L28)`return_url` 的值为定义的 `scheme` => `uiwjspay://`,才会返回[支付宝订单支付状态结果](https://opendocs.alipay.com/open/204/105301#%E8%BF%94%E5%9B%9E%E7%BB%93%E6%9E%9C%E7%A4%BA%E4%BE%8B%EF%BC%88iOS%7CAndroid%EF%BC%89)
2. 在请求支付的 [`payInfo`](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/example/App.js#L11) 中必须包含 [`return_url=uiwjspay://`](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/example/App.js#L11)`return_url` 的值为定义的 `scheme` => `uiwjspay://`,才会返回[支付宝订单支付状态结果](https://opendocs.alipay.com/open/204/105301#%E8%BF%94%E5%9B%9E%E7%BB%93%E6%9E%9C%E7%A4%BA%E4%BE%8B%EF%BC%88iOS%7CAndroid%EF%BC%89)
```js
// payInfo 是后台拼接好的支付参数,这个参数必须包含 `return_url=uiwjspay://`
Alipay.alipay(payInfo, (res)=>console.log(res))
```
3. 用的 `URL Schemes` 列为白名单,在 [`ios/<应用名称>/Info.plist`](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/5daea87bf0af05d60d0ae9e4c04e1e2d1a6e4273/example/ios/example/Info.plist#L23-L41) 中添加
3. 用的 `URL Schemes` 列为白名单,在 [`ios/<应用名称>/Info.plist`](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/example/ios/example/Info.plist#L23-L41) 中添加
```xml
<key>LSApplicationQueriesSchemes</key>
@@ -136,7 +168,7 @@ Alipay.alipay(payInfo, (res)=>console.log(res))
</array>
```
4. 修改 [`ios/<应用名称>/AppDelegate.m`](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/4329bd62443bf377221860cd1acfaa710bbe562d/example/ios/example/AppDelegate.m#L60-L70) 添加下列代码:
4. 修改 [`ios/<应用名称>/AppDelegate.m`](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/example/ios/example/AppDelegate.m#L60-L70) 添加下列代码:
```objective-c
#import <React/RCTLinkingManager.h>

View File

@@ -4,6 +4,7 @@ import com.alipay.sdk.app.AuthTask;
import com.alipay.sdk.app.PayTask;
import com.alipay.sdk.app.EnvUtils;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
@@ -33,6 +34,20 @@ public class AlipayModule extends ReactContextBaseJavaModule {
// callback.invoke("Received numberArgument: " + numberArgument + " stringArgument: " + stringArgument);
// }
@ReactMethod
public void authInfo(final String infoStr, final Promise promise) {
Runnable runnable = new Runnable() {
@Override
public void run() {
AuthTask authTask = new AuthTask(getCurrentActivity());
Map<String, String> map = authTask.authV2(infoStr, true);
promise.resolve(getWritableMap(map));
}
};
Thread thread = new Thread(runnable);
thread.start();
}
@ReactMethod
public void setAlipaySandbox(Boolean isSandbox) {
if (isSandbox) {
@@ -42,17 +57,13 @@ public class AlipayModule extends ReactContextBaseJavaModule {
}
}
@ReactMethod
public void alipay(final String orderInfo, final Callback promise) {
public void alipay(final String orderInfo, final Promise promise) {
Runnable payRunnable = new Runnable() {
@Override
public void run() {
PayTask alipay = new PayTask(getCurrentActivity());
Map<String, String> result = alipay.payV2(orderInfo, true);
WritableMap map = Arguments.createMap();
map.putString("memo", result.get("memo"));
map.putString("result", result.get("result"));
map.putString("resultStatus", result.get("resultStatus"));
promise.invoke(map);
promise.resolve(getWritableMap(result));
}
};
// 必须异步调用
@@ -60,4 +71,17 @@ public class AlipayModule extends ReactContextBaseJavaModule {
payThread.start();
}
@ReactMethod
public void getVersion(Promise promise) {
PayTask payTask = new PayTask(getCurrentActivity());
promise.resolve(payTask.getVersion());
}
private WritableMap getWritableMap(Map<String, String> map) {
WritableMap writableMap = Arguments.createMap();
for (Map.Entry<String, String> entry : map.entrySet()) {
writableMap.putString(entry.getKey(), entry.getValue());
}
return writableMap;
}
}

View File

@@ -1,24 +1,33 @@
import React, { Component } from 'react';
import { Button, StyleSheet, Text, View, Linking, AppState } from 'react-native';
import Alipay from 'react-native-uiwjs-alipay';
import Alipay from '@uiw/react-native-alipay';
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
version: '',
}
}
componentDidMount() {
Alipay.setAlipayScheme('uiwjspay');
}
aliPay = () => {
aliPay = async () => {
// return_url=
const payInfo = 'alipay_sdk=alipay-sdk-java-dynamicVersionNo&app_id=2021001172656340&biz_content=%7B%22out_trade_no%22%3A%221111112222222%22%2C%22total_amount%22%3A%220.01%22%2C%22subject%22%3A%221234%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%7D&charset=UTF-8&format=json&method=alipay.trade.app.pay&notify_url=http%3A%2F%2Fane.boshu.ltd%2Fowner%2Fpay%2Fapi%2FownerPay%2Fcallback&sign=oUQmGtkv8mrhJ0YwHl9%2FfxMcoLACWuSFKiMTC4Id8nc%2FZVvDQ6MLQq5hhtEN03Qn1%2BAtzTAaofE8nNixdroxOek2l5YtOAcYcXVYlJIyogN%2B22erN2NpDTWJ7tQTKgYFDJLRiG0DZJaxfADhUUF6UR9kdA8omoXKLDlP17ZPUs5Jr4aKv5HJtH5C53ui7PbmyWYg934L4UDC2F%2F9pPQlRwwDeE1SAaV3HW9Dt83kK52o8%2FlChXdotbFdAvH0d4qYGhpEYU5sepj9xiOMyL9aC4pMXW9INYLLGbvtqtlRchZTAfH5yji6nqqQm9KKMmcVrWdBDLyjFVNpejq1UjbJBw%3D%3D&sign_type=RSA2&timestamp=2020-07-09+12%3A16%3A16&version=1.0';
Alipay.alipay(payInfo, (resule) => {
console.log('alipay:resule-->>>', resule)
});
const resule = await Alipay.alipay(payInfo);
console.log('alipay:resule-->>>', resule);
}
authInfo = () => {
authInfo = async () => {
const authInfoStr = 'app_name=mc&auth_type=AUTHACCOUNT&apiname=com.alipay.account.auth&biz_type=openservice&product_id=APP_FAST_LOGIN&scope=kuaijie&pid=2088421915791034&target_id=15946456110003465&app_id=2021001172656340&sign_type=RSA2&sign=keluG28qbbLwAcSDI4VmCNOGHJoF3xgpVeqXu1nCBCYo%2FlYYGe00fTfV9L4G73Sk7%2B4IwK%2BZV8IL%2F04cVtk6SR74lKAR3rYOoUdQ09ZrZFuQoUkO0vekajhp75IDQIg6PedCyY0SjFTqrHlH%2FImscBwitxrlSc9YbN7uW0gY34K8t7v8NhDoqzKJeoIz43UxF5U1DpUA1ISBVxwO7du1t6rYltsRhReayPS3hnvmwYSKQZUEgBvJ%2BT2XdyCaz%2FdGV907lYagPp1Oxkoaj%2FvW5NjNsRnid7vH944CoFj9XtBK%2FNTk2tBPTHFxYRQTEG1PkgkBohGpAWOFGGOuapH0ag%3D%3D';
Alipay.authInfo(authInfoStr, (resule) => {
// resule => success=true&auth_code=9c11732de44f4f1790b63978b6fbOX53&result_code=200&alipay_open_id=20881001757376426161095132517425&user_id=2088003646494707
console.log('authInfo:resule-->>>', resule)
});
const resule = await Alipay.authInfo(authInfoStr);
// resule => success=true&auth_code=9c11732de44f4f1790b63978b6fbOX53&result_code=200&alipay_open_id=20881001757376426161095132517425&user_id=2088003646494707
console.log('authInfo:resule-->>>', resule);
}
getVersion = async () => {
const version = await Alipay.getVersion();
this.setState({ version });
console.log('version:', version);
}
render() {
return (
@@ -36,6 +45,12 @@ export default class App extends Component {
color="#841584"
accessibilityLabel="Learn more about this purple button"
/>
<Button
onPress={this.getVersion}
title="获取 SDK 版本"
color="#841584"
/>
<Text>{this.state.version}</Text>
</View>
);
}

View File

@@ -12,7 +12,7 @@
"dependencies": {
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-uiwjs-alipay": "link:../"
"@uiw/react-native-alipay": "link:../"
},
"devDependencies": {
"@babel/core": "^7.6.2",

View File

@@ -617,14 +617,6 @@
pirates "^4.0.0"
source-map-support "^0.5.16"
"@babel/runtime-corejs3@^7.8.3":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.10.4.tgz#f29fc1990307c4c57b10dbd6ce667b27159d9e0d"
integrity sha512-BFlgP2SoLO9HJX9WBwN67gHWMBhDX/eDz64Jajd6mR/UAUzqrNMm99d4qHnVaKscAElZoFiPv+JpR/Siud5lXw==
dependencies:
core-js-pure "^3.0.0"
regenerator-runtime "^0.13.4"
"@babel/runtime@^7.0.0", "@babel/runtime@^7.6.2", "@babel/runtime@^7.8.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.10.4.tgz#a6724f1a6b8d2f6ea5236dbfe58c7d7ea9c5eb99"
@@ -1117,6 +1109,10 @@
lodash.unescape "4.0.1"
semver "5.5.0"
"@uiw/react-native-alipay@link:..":
version "0.0.0"
uid ""
abab@^2.0.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.3.tgz#623e2075e02eb2d3f2475e49f99c91846467907a"
@@ -1918,11 +1914,6 @@ copy-descriptor@^0.1.0:
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=
core-js-pure@^3.0.0:
version "3.6.5"
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.6.5.tgz#c79e75f5e38dbc85a662d91eea52b8256d53b813"
integrity sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA==
core-js@^1.0.0:
version "1.2.7"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
@@ -2029,13 +2020,6 @@ decamelize@^1.2.0:
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=
decamelize@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-3.2.0.tgz#84b8e8f4f8c579f938e35e2cc7024907e0090851"
integrity sha512-4TgkVUsmmu7oCSyGBm5FvfMoACuoh9EOidm7V5/J2X2djAwwt57qb3F2KMP2ITqODTCSwb+YRV+0Zqrv18k/hw==
dependencies:
xregexp "^4.2.4"
decode-uri-component@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
@@ -2167,11 +2151,11 @@ encodeurl@~1.0.2:
integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=
encoding@^0.1.11:
version "0.1.12"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
integrity sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=
version "0.1.13"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9"
integrity sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==
dependencies:
iconv-lite "~0.4.13"
iconv-lite "^0.6.2"
end-of-stream@^1.1.0:
version "1.4.4"
@@ -2996,13 +2980,20 @@ http-signature@~1.2.0:
jsprim "^1.2.2"
sshpk "^1.7.0"
iconv-lite@0.4.24, iconv-lite@^0.4.17, iconv-lite@^0.4.24, iconv-lite@~0.4.13:
iconv-lite@0.4.24, iconv-lite@^0.4.17, iconv-lite@^0.4.24:
version "0.4.24"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"
integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==
dependencies:
safer-buffer ">= 2.1.2 < 3"
iconv-lite@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.2.tgz#ce13d1875b0c3a674bd6a04b7f76b01b1b6ded01"
integrity sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==
dependencies:
safer-buffer ">= 2.1.2 < 3.0.0"
ignore@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
@@ -3081,9 +3072,9 @@ inquirer@^3.0.6:
through "^2.3.6"
inquirer@^7.0.0:
version "7.3.0"
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.0.tgz#aa3e7cb0c18a410c3c16cdd2bc9dcbe83c4d333e"
integrity sha512-K+LZp6L/6eE5swqIcVXrxl21aGDU4S50gKH0/d96OMQnSBCyGyZl/oZhbkVmdp5sBoINHd4xZvFSARh2dk6DWA==
version "7.3.2"
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.2.tgz#25245d2e32dc9f33dbe26eeaada231daa66e9c7c"
integrity sha512-DF4osh1FM6l0RJc5YWYhSDB6TawiBRlbV9Cox8MWlidU218Tb7fm3lQTULyUJDfJ0tjbzl0W4q651mrCCEM55w==
dependencies:
ansi-escapes "^4.2.1"
chalk "^4.1.0"
@@ -3091,7 +3082,7 @@ inquirer@^7.0.0:
cli-width "^3.0.0"
external-editor "^3.0.3"
figures "^3.0.0"
lodash "^4.17.15"
lodash "^4.17.16"
mute-stream "0.0.8"
run-async "^2.4.0"
rxjs "^6.6.0"
@@ -3965,10 +3956,10 @@ lodash.unescape@4.0.1:
resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c"
integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=
lodash@^4.17.10, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.3.0:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
lodash@^4.17.10, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.16, lodash@^4.3.0:
version "4.17.19"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
log-symbols@^2.2.0:
version "2.2.0"
@@ -4903,9 +4894,9 @@ range-parser@~1.2.1:
integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==
react-devtools-core@^4.0.6:
version "4.7.0"
resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-4.7.0.tgz#71e89087352abe60c160dfb60a7fa700f612af7a"
integrity sha512-6w/e0nkV0gogUnfz+9Q3yiMtYYol9T+oD27UIf4XWmula1KvSTTkQ9DnzLOqSSch8d1YzNWbTxguuNJMof58ww==
version "4.8.1"
resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-4.8.1.tgz#16a5e14d6298bd5ebed622cbd039819887405de8"
integrity sha512-Cr70Zjarcpb6egipaShj8NPeBQ0GF1weXHzWQ+r3q02FlBSmFOhLuQkXzGiqJE1ZKNY6u67V+u/ctp7BLgM3qQ==
dependencies:
shell-quote "^1.6.1"
ws "^7"
@@ -4915,10 +4906,6 @@ react-is@^16.12.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
"react-native-uiwjs-alipay@link:../":
version "0.0.0"
uid ""
react-native@0.62.2:
version "0.62.2"
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.62.2.tgz#d831e11a3178705449142df19a70ac2ca16bad10"
@@ -5272,7 +5259,7 @@ safe-regex@^1.1.0:
dependencies:
ret "~0.1.10"
"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0:
"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0:
version "2.1.2"
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
@@ -5695,9 +5682,9 @@ strip-eof@^1.0.0:
integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=
strip-json-comments@^3.0.1:
version "3.1.0"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.0.tgz#7638d31422129ecf4457440009fba03f9f9ac180"
integrity sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w==
version "3.1.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==
sudo-prompt@^9.0.0:
version "9.2.1"
@@ -6088,9 +6075,9 @@ whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3:
iconv-lite "0.4.24"
whatwg-fetch@>=0.10.0, whatwg-fetch@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.1.0.tgz#49d630cdfa308dba7f2819d49d09364f540dbcc6"
integrity sha512-pgmbsVWKpH9GxLXZmtdowDIqtb/rvPyjjQv3z9wLcmgWKFHilKnZD3ldgrOlwJoPGOUluQsRPWd52yVkPfmI1A==
version "3.2.0"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.2.0.tgz#8e134f701f0a4ab5fda82626f113e2b647fd16dc"
integrity sha512-SdGPoQMMnzVYThUbSrEvqTlkvC1Ux27NehaJ/GUHBfNrh5Mjg+1/uRyFMwVnxO2MrikMWvWAqUGgQOfVU4hT7w==
whatwg-mimetype@^2.1.0, whatwg-mimetype@^2.2.0:
version "2.3.0"
@@ -6240,13 +6227,6 @@ xpipe@^1.0.5:
resolved "https://registry.yarnpkg.com/xpipe/-/xpipe-1.0.5.tgz#8dd8bf45fc3f7f55f0e054b878f43a62614dafdf"
integrity sha1-jdi/Rfw/f1Xw4FS4ePQ6YmFNr98=
xregexp@^4.2.4:
version "4.3.0"
resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.3.0.tgz#7e92e73d9174a99a59743f67a4ce879a04b5ae50"
integrity sha512-7jXDIFXh5yJ/orPn4SXjuVrWWoi4Cr8jfV1eHv9CixKSbU+jY4mxfrBwAuDvupPNKpMUY+FeIqsVw/JLT9+B8g==
dependencies:
"@babel/runtime-corejs3" "^7.8.3"
xtend@~4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
@@ -6320,12 +6300,12 @@ yargs@^14.2.0:
yargs-parser "^15.0.1"
yargs@^15.1.0:
version "15.4.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.0.tgz#53949fb768309bac1843de9b17b80051e9805ec2"
integrity sha512-D3fRFnZwLWp8jVAAhPZBsmeIHY8tTsb8ItV9KaAaopmC6wde2u6Yw29JBIZHXw14kgkRnYmDgmQU4FVMDlIsWw==
version "15.4.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"
integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==
dependencies:
cliui "^6.0.0"
decamelize "^3.2.0"
decamelize "^1.2.0"
find-up "^4.1.0"
get-caller-file "^2.0.1"
require-directory "^2.1.1"

13
index.d.ts vendored
View File

@@ -117,15 +117,20 @@ export const Alipay: {
/**
* 支付
* @param payInfo 支付详情
* @param result 支付宝回调结果
* @returns result 支付宝回调结果 https://docs.open.alipay.com/204/105301
*/
alipay: (payInfo: string, callback?: (result: OrderResult) => void) => void;
alipay: (payInfo: string) => Promise<OrderResult>;
/**
* 快速登录授权
* @param authInfoStr 验证详情
* @param result 支付宝回调结果
* @returns result 支付宝回调结果 https://opendocs.alipay.com/open/218/105327
*/
authInfo: (authInfoStr: string, callback?: (result: AuthResult) => void) => void;
authInfo: (authInfoStr: string) => Promise<AuthResult>;
/**
* 获取当前 SDK 版本号
* @return 当前 SDK 版本字符串
*/
getVersion: () => Promise<string>;
/**
* 设置支付宝跳转Scheme仅 iOS
* @param scheme scheme = `ap` + `APPID`

View File

@@ -1,23 +1,30 @@
import { NativeModules, Platform } from 'react-native';
export default class Alipay {
/**
* 支付宝端支付
* 支付
* @param orderInfo 支付详情
* @param callback 支付宝回调结果 详情见 https://docs.open.alipay.com/204/105301
* @returns result 支付宝回调结果 https://docs.open.alipay.com/204/105301
*/
static alipay(orderInfo, callback) {
NativeModules.Alipay.alipay(orderInfo, callback)
static alipay(orderInfo) {
return NativeModules.Alipay.alipay(orderInfo);
}
/**
* 支付宝授权请求信息
* @param infoStr 授权请求信息字串
* @param callback 授权结果回调 详情见 https://opendocs.alipay.com/open/218/105325
* 快速登录授权
* @param authInfoStr 验证详情
* @returns result 支付宝回调结果 详情见 https://opendocs.alipay.com/open/218/105325
*/
static authInfo(infoStr, callback) {
NativeModules.Alipay.authInfo(infoStr, callback)
static authInfo(authInfoStr) {
return NativeModules.Alipay.authInfo(authInfoStr)
}
/**
* 获取当前版本号
* @return 当前版本字符串
*/
static getVersion() {
return NativeModules.Alipay.getVersion()
}
/**

View File

@@ -1,6 +1,12 @@
#import "Alipay.h"
#import <AlipaySDK/AlipaySDK.h>
@interface Alipay ()
@property (nonatomic, copy) RCTPromiseResolveBlock payOrderResolve;
@end
@implementation Alipay
{
NSString *alipayScheme;
@@ -14,6 +20,10 @@ RCT_EXPORT_MODULE()
self = [super init];
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:@"RCTOpenURLNotification" object:nil];
// SDK 便
// [AlipaySDK startLogWithBlock:^(NSString* log){
// NSLog(@"%@", log);
// }];
}
return self;
}
@@ -28,16 +38,27 @@ RCT_EXPORT_MODULE()
NSString * aURLString = [aNotification userInfo][@"url"];
NSURL * aURL = [NSURL URLWithString:aURLString];
if ([aURL.host isEqualToString:@"safepay"]) {
//
__weak __typeof__(self) weakSelf = self;
/**
* appappUrl
*
* @param resultUrl appurl
* @param completionBlock nil使completionBlock
*/
[[AlipaySDK defaultService] processOrderWithPaymentResult:aURL standbyCallback:^(NSDictionary *resultDic) {
if (self->alipayCallBack != nil) {
self->alipayCallBack([[NSArray alloc] initWithObjects:resultDic, nil]);
self->alipayCallBack = nil;
NSLog(@"result-->1 = %@", resultDic);
if (weakSelf.payOrderResolve) {
weakSelf.payOrderResolve(resultDic);
weakSelf.payOrderResolve = nil;
}
NSLog(@"result-->1 = %@",resultDic);
}];
//
/**
* appappUrl
*
* @param aURL appurl
* @param completionBlock ,APP
*/
[[AlipaySDK defaultService] processAuth_V2Result:aURL standbyCallback:^(NSDictionary *resultDic) {
NSLog(@"result-->2 = %@", resultDic);
// auth code
@@ -52,9 +73,9 @@ RCT_EXPORT_MODULE()
}
}
//
if (self->alipayCallBack != nil) {
self->alipayCallBack([[NSArray alloc] initWithObjects:resultArr, nil]);
self->alipayCallBack = nil;
if (weakSelf.payOrderResolve) {
weakSelf.payOrderResolve([[NSArray alloc] initWithObjects:resultArr, nil]);
weakSelf.payOrderResolve = nil;
}
}
NSLog(@"授权结果 authCode = %@", authCode?:@"");
@@ -63,28 +84,25 @@ RCT_EXPORT_MODULE()
return NO;
}
RCT_EXPORT_METHOD(setAlipayScheme:(NSString *)scheme){
RCT_EXPORT_METHOD(setAlipayScheme:(NSString *)scheme) {
alipayScheme = scheme;
}
RCT_EXPORT_METHOD(alipay:(NSString *)info callback:(RCTResponseSenderBlock)callback)
{
alipayCallBack = callback;
dispatch_async(dispatch_get_main_queue(), ^{
[[AlipaySDK defaultService] payOrder:info fromScheme: alipayScheme callback:^(NSDictionary *resultDic) {
callback([[NSArray alloc] initWithObjects:resultDic, nil]);
}];
});
RCT_EXPORT_METHOD(alipay:(NSString *)info resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
self.payOrderResolve = resolve;
[AlipaySDK.defaultService payOrder:info fromScheme: alipayScheme callback:^(NSDictionary *resultDic) {
resolve(resultDic);
}];
}
RCT_EXPORT_METHOD(authInfo:(NSString *)info callback:(RCTResponseSenderBlock)callback)
{
alipayCallBack = callback;
dispatch_async(dispatch_get_main_queue(), ^{
[[AlipaySDK defaultService] auth_V2WithInfo:info fromScheme:alipayScheme callback:^(NSDictionary *resultDic) {
callback([[NSArray alloc] initWithObjects:resultDic, nil]);
}];
});
RCT_EXPORT_METHOD(authInfo:(NSString *)info resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
[AlipaySDK.defaultService auth_V2WithInfo:info fromScheme: alipayScheme callback:^(NSDictionary *resultDic) {
resolve(resultDic);
}];
}
RCT_EXPORT_METHOD(getVersion: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
resolve([[AlipaySDK defaultService] currentVersion]);
}
/*!

View File

@@ -1,22 +1,22 @@
require "json"
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
package = JSON.parse(File.read(File.join(__dir__, "..", "package.json")))
Pod::Spec.new do |s|
s.name = "react-native-uiwjs-alipay"
s.name = "Alipay"
s.version = package["version"]
s.summary = package["description"]
s.description = <<-DESC
react-native-uiwjs-alipay
Alipay SDK for React Native
DESC
s.homepage = "https://github.com/uiwjs/react-native-uiwjs-alipay"
s.homepage = "https://github.com/uiwjs/react-native-alipay"
# brief license entry:
s.license = "MIT"
# optional - use expanded license entry instead:
# s.license = { :type => "MIT", :file => "LICENSE" }
s.authors = { "Kenny Wong" => "wowohoo@qq.com" }
s.platforms = { :ios => "9.0" }
s.source = { :git => "https://github.com/uiwjs/react-native-uiwjs-alipay.git", :tag => "#{s.version}" }
s.source = { :git => "https://github.com/uiwjs/react-native-alipay.git", :tag => "#{s.version}" }
s.source_files = "ios/**/*.{h,c,m,swift}"
s.requires_arc = true

View File

@@ -1,25 +1,31 @@
{
"name": "react-native-uiwjs-alipay",
"version": "1.3.0",
"description": "基于 React Native 的宝支付插件",
"name": "@uiw/react-native-alipay",
"version": "2.0.6",
"description": "基于 React Native 的宝支付插件支持Android/iOS。",
"main": "index.js",
"files": [
"README.md",
"android",
"index.js",
"ios",
"react-native-uiwjs-alipay.podspec"
"react-native-alipay.podspec"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/uiwjs/react-native-uiwjs-alipay.git",
"baseUrl": "https://github.com/uiwjs/react-native-uiwjs-alipay"
"url": "git+https://github.com/uiwjs/react-native-alipay.git",
"baseUrl": "https://github.com/uiwjs/react-native-alipay"
},
"keywords": [
"react-native"
"react-native",
"alipay",
"uiwjs",
"uiw",
"支付宝",
"ios",
"android"
],
"author": {
"name": "Kenny Wong",