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

Compare commits

...

25 Commits

Author SHA1 Message Date
jaywcjlove
3d35ed67e4 released v1.2.0 2020-07-09 18:58:16 +08:00
jaywcjlove
55bfe74932 doc: Update README.md 2020-07-09 18:57:46 +08:00
jaywcjlove
38e73ca823 chore: Update example. 2020-07-09 18:57:17 +08:00
jaywcjlove
0d174dcda0 fix: Fix wrong parameter name. 2020-07-09 18:56:50 +08:00
jaywcjlove
742e40d922 fix(Android): Fix app name issue. 2020-07-09 18:55:35 +08:00
jaywcjlove
240965be2a doc: Update README.md 2020-07-09 10:35:19 +08:00
jaywcjlove
5daea87bf0 doc: Update README.md 2020-07-09 10:31:50 +08:00
jaywcjlove
f6d21b6b7e chore: Modify iOS Schemes. 2020-07-09 10:06:23 +08:00
jaywcjlove
0ec59424d8 released v1.1.0 2020-07-08 23:14:22 +08:00
jaywcjlove
aba68a6170 doc: Update README.md 2020-07-08 23:13:06 +08:00
jaywcjlove
1a54d02a47 doc: Update README.md 2020-07-08 23:09:53 +08:00
jaywcjlove
e47161fa5b doc: Update README.md 2020-07-08 23:08:37 +08:00
jaywcjlove
1eff1dd94f doc: Update README.md 2020-07-08 23:04:57 +08:00
jaywcjlove
09d363da5c doc: Update README.md 2020-07-08 23:02:36 +08:00
jaywcjlove
866f388945 doc: Update README.md 2020-07-08 23:00:16 +08:00
jaywcjlove
bc61ace241 doc: Update README.md 2020-07-08 22:56:56 +08:00
jaywcjlove
4329bd6244 doc: Update README.md 2020-07-08 22:46:38 +08:00
jaywcjlove
cdc5ca58d9 doc: Update README.md 2020-07-08 22:45:39 +08:00
jaywcjlove
b8b5b3e6e5 doc: Update README.md 2020-07-08 22:40:06 +08:00
jaywcjlove
08da574fc7 doc: Update README.md 2020-07-08 22:38:21 +08:00
jaywcjlove
687ea94cb0 doc(iOS): 更新接入说明文档。 2020-07-08 22:36:20 +08:00
jaywcjlove
96c86045a9 type: 更新类型文件。 2020-07-08 22:32:18 +08:00
jaywcjlove
866888a3ed Merge branch 'master' of github.com:uiwjs/react-native-uiwjs-alipay 2020-07-08 22:08:43 +08:00
jaywcjlove
07cc6c69ff chore: Update Example. 2020-07-08 22:05:37 +08:00
Renovate Bot
8881148994 chore(deps): add renovate.json 2020-07-08 10:46:33 +08:00
13 changed files with 232 additions and 75 deletions

113
README.md
View File

@@ -1,11 +1,13 @@
react-native-uiwjs-alipay
===
基于 React Native 的宝支付插件。
基于 React Native 的宝支付插件。适用于商家在 App 应用中集成支付宝支付功能,商家 APP 调用支付宝提供的 SDKSDK 再调用支付宝 APP 内的支付模块。如果用户已安装支付宝APP商家APP会跳转到支付宝中完成支付支付完后跳回到商家 APP 内,最后展示支付结果。如果用户没有安装支付宝 APP商家 APP 内会调起支付宝网页支付收银台,用户登录支付宝账户,支付完后展示支付结果。完整实例 [Example](./example)
1. Android支持2.3及以上的系统版本运行
2. iOSiOS 6.0以上(包含iOS 6.0)
3. 支持手机系统iOS苹果、Android安卓
1. Android支持2.3及以上的系统版本运行
2. iOSiOS 6.0以上(包含iOS 6.0)
3. 支持手机系统iOS苹果、Android安卓
4. 调试请注意 支付宝接入应用必须 `已审核通过`
5. 适用于 `react-native >= 0.60+` 低版本未测试。
## Getting started
@@ -13,40 +15,110 @@ react-native-uiwjs-alipay
yarn add react-native-uiwjs-alipay
# react-native version >= 0.60+
$ cd ios && pod install
# or
$ react-native link react-native-uiwjs-alipay
```
## Usage
> ⚠️ 注意支付成功返回结果是一个字符串,[返回内容](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/96c86045a92b7668b51658c3e696d3cd0e5f2f9e/index.d.ts#L2-L82)
> 支付宝需要设置 `Scheme`
```javascript
import Alipay from 'react-native-uiwjs-alipay';
// 设置 支付宝 URL Schemes
// scheme = `ap` + `APPID`
// 设置 支付宝 URL Schemes,要表述他是宇宙唯一性,可以使用 `bundle Identifier`
// scheme = `alipay` + `APPID``APPID` 为支付宝分配给开发者的应用ID
Alipay.setAlipayScheme(scheme);
// 设置支付宝沙箱环境
Alipay.setAlipaySandbox(isSandbox);
// 支付宝 iOS 端的支付
// ⚠️ 目前不可用,设置支付宝沙箱环境,仅 Android 支持
// Alipay.setAlipaySandbox(isSandbox);
// 支付宝支付
// payInfo 是后台拼接好的支付参数
Alipay.alipay(payInfo, (res)=>console.log(res))
Alipay.alipay(payInfo, (res)=> console.log(res))
```
订单详情 [`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) 编码前的数据
```bash
app_id=xxxxxxxxx&biz_content={"timeout_express":"30m","product_code":"QUICK_MSECURITY_PAY","total_amount":"0.01","subject":"1","body":"我是测试数据","out_trade_no":"IQJZSRC1YMQB5HU"}&charset=utf-8&format=json&method=alipay.trade.app.pay&notify_url=http://domain.merchant.com/payment_notify&sign_type=RSA2&timestamp=2016-08-25 20:26:31&version=1.0&sign=cYmuUnKi5QdBsoZEAbMXVMmRWjsuUj+y48A2DvWAVVBuYkiBj13CFDHu2vZQvmOfkjE0YqCUQE04kqm9Xg3tIX8tPeIGIFtsIyp/M45w1ZsDOiduBbduGfRo1XRsvAyVAv2hCrBLLrDI5Vi7uZZ77Lo5J0PpUUWwyQGt0M4cj8g=
alipay_sdk=alipay-sdk-java-dynamicVersionNo&app_id=xxxxxxxxxxxxx&biz_content={ "out_trade_no":"123123123123123", "total_amount":"0.01", "subject":"1234", "product_code":"QUICK_MSECURITY_PAY" }&charset=UTF-8&format=json&method=alipay.trade.app.pay&notify_url=http://ane.boshu.ltd/owner/pay/api/ownerPay/callback&return_url=uiwjspay://&sign=re/+2SICQggOUjfxl7MtP/qzir2e+LdH4m+02gDcw0fkByO5MqXW/9bmXw+c4RMqo835OAjMZs7s966ZuDx2PB+hO0tJ/bzdHLLqYlBeCcETkrfwRx+AFZNgzsCn75eRCA7GONH35BpfSeGkQUZ+vNXftqd6hWaa7m/MhQYrjQcV98IVJM+UR67Gj68c+LM586cnk0+rbj8zoos6tCvN8c3xx5UaCobzw4Ogf0PWZ7PZROTU9w2gtoxFfOC5d5slN3laaAXVjAxSf9JCNs8q95fDbzpbmstQOuPgGHkASkd/beH0F8eqTVv8gW1ZTo5v/d/E2wSDGV1DciaEnCroTw==&sign_type=RSA2&timestamp=2020-07-09 09:50:41&version=1.0
```
订单详情 `payInfo` 编码的数据
> 订单参数通过 `encodeURIComponent` 编码 和 `decodeURIComponent` 解码。
```bash
app_id=xxxxxxxxx&biz_content=%7B%22timeout_express%22%3A%2230m%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22total_amount%22%3A%220.01%22%2C%22subject%22%3A%221%22%2C%22body%22%3A%22%E6%88%91%E6%98%AF%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%22%2C%22out_trade_no%22%3A%22IQJZSRC1YMQB5HU%22%7D&charset=utf-8&format=json&method=alipay.trade.app.pay&notify_url=http%3A%2F%2Fdomain.merchant.com%2Fpayment_notify&sign_type=RSA2&timestamp=2016-08-25%2020%3A26%3A31&version=1.0&sign=cYmuUnKi5QdBsoZEAbMXVMmRWjsuUj%2By48A2DvWAVVBuYkiBj13CFDHu2vZQvmOfkjE0YqCUQE04kqm9Xg3tIX8tPeIGIFtsIyp%2FM45w1ZsDOiduBbduGfRo1XRsvAyVAv2hCrBLLrDI5Vi7uZZ77Lo5J0PpUUWwyQGt0M4cj8g%3D
alipay_sdk=alipay-sdk-java-dynamicVersionNo&app_id=xxxxxxxxxxxxx&biz_content=%7B+%22out_trade_no%22%3A%22123123123123123%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&return_url=uiwjspay%3A%2F%2F&sign=re%2F%2B2SICQggOUjfxl7MtP%2Fqzir2e%2BLdH4m%2B02gDcw0fkByO5MqXW%2F9bmXw%2Bc4RMqo835OAjMZs7s966ZuDx2PB%2BhO0tJ%2FbzdHLLqYlBeCcETkrfwRx%2BAFZNgzsCn75eRCA7GONH35BpfSeGkQUZ%2BvNXftqd6hWaa7m%2FMhQYrjQcV98IVJM%2BUR67Gj68c%2BLM586cnk0%2Brbj8zoos6tCvN8c3xx5UaCobzw4Ogf0PWZ7PZROTU9w2gtoxFfOC5d5slN3laaAXVjAxSf9JCNs8q95fDbzpbmstQOuPgGHkASkd%2FbeH0F8eqTVv8gW1ZTo5v%2Fd%2FE2wSDGV1DciaEnCroTw%3D%3D&sign_type=RSA2&timestamp=2020-07-09+09%3A50%3A41&version=1.0
```
### 其它
- ⚠️ 后台 SDK 根据所有数据生成 `sign`,建议通过 API 拿到这个数据,拼接数据会报错。
- ⚠️ `out_trade_no` 订单 id 和 `sign` 签名 是唯一的,每次不一样,需要后台生成。
## 支付宝返回应用 iOS 设置
⚠️ Android 端不需要做任何设置。
⚠️ 如果用户从 `支付宝App` 跳转到 `商家APP`,是通过系统功能切换,而不是通过 `支付宝APP` 功能键返回 `商家APP`,回调函数是不起作用的,可通过 [`AppState.addEventListener`](https://github.com/uiwjs/react-native-uiwjs-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` 唯一性。
```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)
```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) 中添加
```xml
<key>LSApplicationQueriesSchemes</key>
<array>
<string>alipay</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>uiwjspay</string>
</array>
</dict>
</array>
```
4. 修改 [`ios/<应用名称>/AppDelegate.m`](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/4329bd62443bf377221860cd1acfaa710bbe562d/example/ios/example/AppDelegate.m#L60-L70) 添加下列代码:
```objective-c
#import <React/RCTLinkingManager.h>
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [RCTLinkingManager application:application openURL:url
sourceApplication:sourceApplication annotation:annotation];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
{
return [RCTLinkingManager application:application openURL:url options:options];
}
```
命令测试 `xcrun simctl openurl booted uiwjspay://`
## 错误处理
```bash
[NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x283317100, domain=1, instance=1>
```
在 `Product` -> `Scheme` -> `Edit Scheme` -> `Run` -> `Environment Variables` 添加 `OS_ACTIVITY_MODE` `disable`
## 其它
当前工程基于 [@brodybits/create-react-native-module](https://github.com/brodybits/create-react-native-module) 初始化。
@@ -54,8 +126,9 @@ app_id=xxxxxxxxx&biz_content=%7B%22timeout_express%22%3A%2230m%22%2C%22product_c
npx create-react-native-module --package-identifier com.uiwjs --generate-example Alipay --example-react-native-version 0.62.2 --module-name react-native-uiwjs-alipay --github-account uiwjs --author-name "Kenny Wong" --author-email "wowohoo@qq.com"
```
### 相关连接
## 相关连接
- [React-native 0.6版本集成支付宝-Alipay爬坑](https://segmentfault.com/a/1190000020758279)
- [支付宝生成秘钥指南](https://opendocs.alipay.com/open/291/105971)
- [支付宝 SDK 下载地址](https://opendocs.alipay.com/open/54/104509)
- [支付宝 SDK 下载地址,当前使用的是 AlipaySDK 15.7.7](https://opendocs.alipay.com/open/54/104509)
- [客户端调试工具及使用教程](https://openclub.alipay.com/club/history/read/7695)
- [React-native 0.6版本集成支付宝-Alipay爬坑](https://segmentfault.com/a/1190000020758279)

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">uiwjs</string>
</resources>

View File

@@ -1,15 +1,32 @@
import React, { Component } from 'react';
import { Button, StyleSheet, Text, View } from 'react-native';
import { Button, StyleSheet, Text, View, Linking, AppState } from 'react-native';
import Alipay from 'react-native-uiwjs-alipay';
export default class App extends Component {
componentDidMount() {
Alipay.setAlipayScheme('ap2021001172656340');
Alipay.setAlipayScheme('uiwjspay');
AppState.addEventListener('change', this._handleAppStateChange);
}
componentWillUnmount(){
AppState.removeEventListener('change', this._handleAppStateChange)
}
// [info][tid:com.facebook.react.JavaScript] 'nextAppState:', 'inactive'
// [info][tid:com.facebook.react.JavaScript] 'nextAppState:', 'background'
// [info][tid:com.facebook.react.JavaScript] 'nextAppState:', 'active'
// [info][tid:com.facebook.react.JavaScript] 'nextAppState:res:', null
_handleAppStateChange = (nextAppState) => {
console.log('nextAppState:', nextAppState)
if(nextAppState==='active'){
Linking.getInitialURL().then(res => {
console.log('nextAppState:res:', res)
})
}
}
aliPay = () => {
const payInfo = 'app_id=2021001172656340&biz_content=%7B%22timeout_express%22%3A%2230m%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22total_amount%22%3A%220.01%22%2C%22subject%22%3A%221%22%2C%22body%22%3A%22%E6%88%91%E6%98%AF%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%22%2C%22out_trade_no%22%3A%22IQJZSRC1YMQB5HU%22%7D&charset=utf-8&format=json&method=alipay.trade.app.pay&notify_url=http%3A%2F%2Fdomain.merchant.com%2Fpayment_notify&sign_type=RSA2&timestamp=2016-08-25%2020%3A26%3A31&version=1.0&sign=cYmuUnKi5QdBsoZEAbMXVMmRWjsuUj%2By48A2DvWAVVBuYkiBj13CFDHu2vZQvmOfkjE0YqCUQE04kqm9Xg3tIX8tPeIGIFtsIyp%2FM45w1ZsDOiduBbduGfRo1XRsvAyVAv2hCrBLLrDI5Vi7uZZ77Lo5J0PpUUWwyQGt0M4cj8g%3D';
// 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(resule)
console.log('resule-->>>', resule)
});
}
render() {

View File

@@ -1,7 +1,3 @@
rootProject.name = 'example'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
// 看上去可以自动的样子
// include ':react-native-uiwjs-alipay'
// project(':react-native-uiwjs-alipay').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-uiwjs-alipay/android')

View File

@@ -681,7 +681,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.uiwjs;
PRODUCT_NAME = example;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
@@ -704,7 +704,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.uiwjs;
PRODUCT_NAME = example;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";

View File

@@ -60,6 +60,13 @@
ReferencedContainer = "container:example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<EnvironmentVariables>
<EnvironmentVariable
key = "OS_ACTIVITY_MODE"
value = "disable"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"

View File

@@ -3,6 +3,7 @@
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLinkingManager.h>
#if DEBUG
#import <FlipperKit/FlipperClient.h>
@@ -55,4 +56,16 @@ static void InitializeFlipper(UIApplication *application) {
#endif
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [RCTLinkingManager application:application openURL:url
sourceApplication:sourceApplication annotation:annotation];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
{
return [RCTLinkingManager application:application openURL:url options:options];
}
@end

View File

@@ -26,17 +26,21 @@
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>I</string>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>uiwjspay</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>alipay</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>

113
index.d.ts vendored
View File

@@ -4,51 +4,90 @@
* 支付宝回调结果, 详情见 https://docs.open.alipay.com/204/105301
*/
export interface AliOrderResult {
/**
* 长度64商户网站唯一订单号 70501111111S001111119
*/
out_trade_no: string;
/**
* 长度64该交易在支付宝系统中的交易流水号。最长64位。 2014112400001000340011111118
*/
trade_no: string;
/**
* 长度32支付宝分配给开发者的应用Id。 2014072300007148
*/
app_id: string;
/**
* 长度9 该笔订单的资金总额单位为RMB-Yuan。取值范围为[0.01,100000000.00],精确到小数点后两位。 9.00
*/
total_amount: number;
/**
* 长度16收款支付宝账号对应的支付宝唯一用户号。以2088开头的纯16位数字 20886894
*/
seller_id: string;
/**
* 长度16处理结果的描述信息来自于code返回结果的描述 success
*/
msg: string;
/**
* 长度16编码格式 utf-8
*/
charset: string;
/**
* 长度32时间 2016-10-11 17:43:36
*/
timestamp: string;
/**
* 长度16结果码 具体见公共错误码
*/
code: string;
alipay_trade_app_pay_response: {
/**
* 长度64商户网站唯一订单号 70501111111S001111119
*/
out_trade_no: string;
/**
* 长度64该交易在支付宝系统中的交易流水号。最长64位。 2014112400001000340011111118
*/
trade_no: string;
/**
* 长度32支付宝分配给开发者的应用Id。 2014072300007148
*/
app_id: string;
/**
* 长度9 该笔订单的资金总额单位为RMB-Yuan。取值范围为[0.01,100000000.00],精确到小数点后两位。 9.00
*/
total_amount: number;
/**
* 长度16收款支付宝账号对应的支付宝唯一用户号。以2088开头的纯16位数字 20886894
*/
seller_id: string;
/**
* 长度16处理结果的描述信息来自于code返回结果的描述 success
*/
msg: string;
/**
* 长度16编码格式 utf-8
*/
charset: string;
/**
* 长度32时间 2016-10-11 17:43:36
*/
timestamp: string;
/**
* 长度16结果码 具体见公共错误码
*/
code: string;
},
sign: string;
sign_type: 'RSA2' | 'RSA';
}
interface Resule {
/**
* "Error Domain=系统繁忙,请稍后再试 Code=1000 "(null)""
* 优惠券备注信息
*/
memo: string;
result?: string;
/**
* 9000 订单支付成功
* 8000 正在处理中,支付结果未知(有可能已经支付成功),请查询商户订单列表中订单的支付状态
* 4000 订单支付失败
* 5000 重复请求
* 6001 用户中途取消
* 6002 网络连接出错
* 6004 支付结果未知(有可能已经支付成功),请查询商户订单列表中订单的支付状态
* 其它 其它支付错误
*/
resultStatus?: '9000' | '8000' | '4000' | '5000' | '6001' | '6002' | '6004' | string;
}
// 错误返回
// {
// memo: "Error Domain=系统繁忙,请稍后再试 Code=1000 \"(null)\"",
// result: "",
// resultStatus: "4000",
// }
// 成功返回
// {
// result: '{"alipay_trade_app_pay_response":{"code":"10000","msg":"Success","app_id":"2021001172656340","auth_app_id":"2021001172656340","charset":"UTF-8","timestamp":"2020-07-08 21:30:14","out_trade_no":"123123213123214","total_amount":"0.01","trade_no":"2020070822001414841426413774","seller_id":"2088421915791034"},"sign":"LY7wCsNLp+QnDqCq6VelY/RvyK7ZGY8wsXoKvS+Or7JjONLDUx5P6lDgqRKkpkng7br3y6GZzfGKaZ88Tf4eMnBMKyqU+huR2Um47xUxP383njvHlxuQZsSTLQZRswy4wmb/fPkFfvyH6Or6+oj0eboePOTu63bNr+h03w0QnP4znuHpfRuoVgWpsYh/6B1DL+4xfWRKJ21zm1SV9Feo9RWqnyTaGZyFVi6IKge0dUCYs9hXju95fOUVUOx5YflOFtSEnZafY9Ls4FCRQE1ANkjaKiKIE0+c4c4sEVEf/9Dwh88N+aSQOoLT+AV4RpjMoA8hF2k+vv2OKNeqr6SYGQ==","sign_type":"RSA2"}',
// resultStatus: '9000',
// memo: ''
// }
export const Alipay: {
/**
* @param payInfo 支付详情
* @param result 支付宝回调结果
*/
alipay: (payInfo: string, callback?: (result: AliOrderResult) => void) => void;
alipay: (payInfo: string, callback?: (result: Resule) => void) => void;
/**
* 设置支付宝跳转Scheme仅 iOS
* @param scheme scheme = `ap` + `APPID`

View File

@@ -8,7 +8,7 @@ export default class Alipay {
* @param callback 支付宝回调结果 详情见 https://docs.open.alipay.com/204/105301
*/
static alipay(orderInfo, callback) {
NativeModules.Alipay.alipay(orderInfo, callback)
NativeModules.Alipay.alipay(orderInfo, callback)
}
/**
@@ -25,7 +25,7 @@ export default class Alipay {
* 设置支付宝沙箱环境,仅 Android
* @param isSandBox
*/
static setAlipaySandbox(isSandbox) {
static setAlipaySandbox(isSandBox) {
if (Platform.OS === 'android') {
NativeModules.Alipay.setAlipaySandbox(isSandBox);
}

View File

@@ -34,12 +34,12 @@ RCT_EXPORT_MODULE()
self->alipayCallBack([[NSArray alloc] initWithObjects:resultDic, nil]);
self->alipayCallBack = nil;
}
NSLog(@"result = %@",resultDic);
NSLog(@"result-->1 = %@",resultDic);
}];
//
[[AlipaySDK defaultService] processAuth_V2Result:aURL standbyCallback:^(NSDictionary *resultDic) {
NSLog(@"result = %@",resultDic);
NSLog(@"result-->2 = %@", resultDic);
// auth code
NSString *result = resultDic[@"result"];
NSString *authCode = nil;

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-uiwjs-alipay",
"version": "1.0.1",
"version": "1.2.0",
"description": "基于 React Native 的宝支付插件",
"main": "index.js",
"files": [

5
renovate.json Normal file
View File

@@ -0,0 +1,5 @@
{
"extends": [
"config:base"
]
}