Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0ec59424d8 | ||
![]() |
aba68a6170 | ||
![]() |
1a54d02a47 | ||
![]() |
e47161fa5b | ||
![]() |
1eff1dd94f | ||
![]() |
09d363da5c | ||
![]() |
866f388945 | ||
![]() |
bc61ace241 | ||
![]() |
4329bd6244 | ||
![]() |
cdc5ca58d9 | ||
![]() |
b8b5b3e6e5 | ||
![]() |
08da574fc7 | ||
![]() |
687ea94cb0 | ||
![]() |
96c86045a9 | ||
![]() |
866888a3ed | ||
![]() |
07cc6c69ff | ||
![]() |
8881148994 |
96
README.md
96
README.md
@@ -1,11 +1,12 @@
|
|||||||
react-native-uiwjs-alipay
|
react-native-uiwjs-alipay
|
||||||
===
|
===
|
||||||
|
|
||||||
基于 React Native 的宝支付插件。
|
基于 React Native 的宝支付插件。适用于商家在 App 应用中集成支付宝支付功能,商家 APP 调用支付宝提供的 SDK,SDK 再调用支付宝 APP 内的支付模块。如果用户已安装支付宝APP,商家APP会跳转到支付宝中完成支付,支付完后跳回到商家 APP 内,最后展示支付结果。如果用户没有安装支付宝 APP,商家 APP 内会调起支付宝网页支付收银台,用户登录支付宝账户,支付完后展示支付结果。完整实例 [Example](./example)
|
||||||
|
|
||||||
1. Android:支持2.3及以上的系统版本运行
|
1. Android:支持2.3及以上的系统版本运行
|
||||||
2. iOS:iOS 6.0以上(包含iOS 6.0)
|
2. iOS:iOS 6.0以上(包含iOS 6.0)
|
||||||
3. 支持手机系统:iOS(苹果)、Android(安卓)
|
3. 支持手机系统:iOS(苹果)、Android(安卓)
|
||||||
|
4. 调试请注意 支付宝接入应用必须 `已审核通过`
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
@@ -19,15 +20,18 @@ $ react-native link react-native-uiwjs-alipay
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
> ⚠️ 注意支付成功返回结果是一个字符串,[返回内容](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/96c86045a92b7668b51658c3e696d3cd0e5f2f9e/index.d.ts#L2-L82)
|
||||||
|
> 支付宝需要设置 `Scheme`
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import Alipay from 'react-native-uiwjs-alipay';
|
import Alipay from 'react-native-uiwjs-alipay';
|
||||||
|
|
||||||
// 设置 支付宝 URL Schemes
|
// 设置 支付宝 URL Schemes,`APPID` 为支付宝分配给开发者的应用ID
|
||||||
// scheme = `ap` + `APPID`
|
// scheme = `ap` + `APPID`
|
||||||
Alipay.setAlipayScheme(scheme);
|
Alipay.setAlipayScheme(scheme);
|
||||||
// 设置支付宝沙箱环境
|
// 设置支付宝沙箱环境,仅 Android 支持
|
||||||
Alipay.setAlipaySandbox(isSandbox);
|
Alipay.setAlipaySandbox(isSandbox);
|
||||||
// 支付宝 iOS 端的支付
|
// 支付宝端支付
|
||||||
// payInfo 是后台拼接好的支付参数
|
// payInfo 是后台拼接好的支付参数
|
||||||
Alipay.alipay(payInfo, (res)=>console.log(res))
|
Alipay.alipay(payInfo, (res)=>console.log(res))
|
||||||
```
|
```
|
||||||
@@ -35,18 +39,86 @@ 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) 编码前的数据
|
订单详情 [`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
|
```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¬ify_url=http://domain.merchant.com/payment_notify&sign_type=RSA2×tamp=2016-08-25 20:26:31&version=1.0&sign=cYmuUnKi5QdBsoZEAbMXVMmRWjsuUj+y48A2DvWAVVBuYkiBj13CFDHu2vZQvmOfkjE0YqCUQE04kqm9Xg3tIX8tPeIGIFtsIyp/M45w1ZsDOiduBbduGfRo1XRsvAyVAv2hCrBLLrDI5Vi7uZZ77Lo5J0PpUUWwyQGt0M4cj8g=
|
alipay_sdk=alipay-sdk-java-dynamicVersionNo&app_id=xxxxxxxxxxxxxxxx&biz_content={ "out_trade_no":"1111144444", "total_amount":"0.01", "subject":"12321313655555555", "product_code":"QUICK_MSECURITY_PAY" }&charset=UTF-8&format=json&method=alipay.trade.app.pay¬ify_url=http://ane.boshu.ltd/owner/pay/api/ownerPay/callback&return_url=http://domain.com/CallBack/return_url.jsp&sign=FP5fLb/l2LoijO7k0BrmEvWKfuG7oIbYA/4VVL9mI0/SWAEzt27Zp09LK2xsDKaW0oGJ38aGhtDxGIHqZDMvbhTooB6jeRH+2m1wM5hyDq1vbc8CzfL+OSfRoQ3RQ4j50gbO0oABOUvaSb/xK8Tzix7HfDpMfjtqhN+81fiET2Q19dxcOmu22GAWE4/ZPrbASsVfi1r/OXLdeDjkqdUTy9lOGJqg2bgTKy6BaYcelc/nEpuaF0mDXbHJX1vmra7vd8rhczy11rEVaHofMnPVZr3hucMuBH/fxOXQZuZcAmyaWr+NT8hVetxZaTgyhK9fqxjGcxPijc+pWWTwMxt4YA==&sign_type=RSA2×tamp=2020-07-08 17:07:36&version=1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
订单详情 `payInfo` 编码的数据
|
订单详情 `payInfo` 编码的数据
|
||||||
|
|
||||||
> 订单参数通过 `encodeURIComponent` 编码 和 `decodeURIComponent` 解码。
|
|
||||||
|
|
||||||
```bash
|
```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¬ify_url=http%3A%2F%2Fdomain.merchant.com%2Fpayment_notify&sign_type=RSA2×tamp=2016-08-25%2020%3A26%3A31&version=1.0&sign=cYmuUnKi5QdBsoZEAbMXVMmRWjsuUj%2By48A2DvWAVVBuYkiBj13CFDHu2vZQvmOfkjE0YqCUQE04kqm9Xg3tIX8tPeIGIFtsIyp%2FM45w1ZsDOiduBbduGfRo1XRsvAyVAv2hCrBLLrDI5Vi7uZZ77Lo5J0PpUUWwyQGt0M4cj8g%3D
|
alipay_sdk=alipay-sdk-java-dynamicVersionNo&app_id=xxxxxxxxxxxxxxxx&biz_content=%7B+%22out_trade_no%22%3A%221111144444%22%2C+%22total_amount%22%3A%220.01%22%2C+%22subject%22%3A%2212321313655555555%22%2C+%22product_code%22%3A%22QUICK_MSECURITY_PAY%22+%7D&charset=UTF-8&format=json&method=alipay.trade.app.pay¬ify_url=http%3A%2F%2Fane.boshu.ltd%2Fowner%2Fpay%2Fapi%2FownerPay%2Fcallback&return_url=http%3A%2F%2Fdomain.com%2FCallBack%2Freturn_url.jsp&sign=FP5fLb%2Fl2LoijO7k0BrmEvWKfuG7oIbYA%2F4VVL9mI0%2FSWAEzt27Zp09LK2xsDKaW0oGJ38aGhtDxGIHqZDMvbhTooB6jeRH%2B2m1wM5hyDq1vbc8CzfL%2BOSfRoQ3RQ4j50gbO0oABOUvaSb%2FxK8Tzix7HfDpMfjtqhN%2B81fiET2Q19dxcOmu22GAWE4%2FZPrbASsVfi1r%2FOXLdeDjkqdUTy9lOGJqg2bgTKy6BaYcelc%2FnEpuaF0mDXbHJX1vmra7vd8rhczy11rEVaHofMnPVZr3hucMuBH%2FfxOXQZuZcAmyaWr%2BNT8hVetxZaTgyhK9fqxjGcxPijc%2BpWWTwMxt4YA%3D%3D&sign_type=RSA2×tamp=2020-07-08+17%3A07%3A36&version=1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
### 其它
|
- ⚠️ 后台 SDK 根据所有数据生成 `sign`,建议通过 API 拿到这个数据,拼接数据会报错。
|
||||||
|
- ⚠️ `out_trade_no` 订单 id 和 `sign` 签名 是唯一的,每次不一样,需要后台生成。
|
||||||
|
|
||||||
|
## 支付宝返回应用 iOS 设置
|
||||||
|
|
||||||
|
⚠️ 如果用户从 `支付宝App` 跳转到 `商家APP`,是通过系统功能切换,而不是通过 `支付宝APP` 功能键返回 `商家APP`,回调函数是不起作用的,可通过 [`AppState.addEventListener`](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/b8b5b3e6e53bb23d1503cd9c565ad8f2132e2404/example/App.js#L6-L24) 监听事件请求后台 API,来优化这一用户体验。
|
||||||
|
|
||||||
|
1. 在代码中设置支付宝 [`URL Schemes`](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/1eff1dd94f3ae733db2913400e1aac382d056871/example/App.js#L7),下面实例为 `ap2021001172656340` 为定义的 `scheme` = `ap` + `appid`,`appid` 为支付宝分配给开发者的应用ID
|
||||||
|
|
||||||
|
```js
|
||||||
|
// scheme = `ap` + `appid`
|
||||||
|
Alipay.setAlipayScheme('ap2021001172656340');
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 在请求支付的 [`payInfo`](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/1eff1dd94f3ae733db2913400e1aac382d056871/example/App.js#L27-L30) 中必须包含 [`return_url=ap2021001172656340`](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/1eff1dd94f3ae733db2913400e1aac382d056871/example/App.js#L27-L30),`return_url` 的值为定义的 `scheme` => `ap2021001172656340://`,才会返回[支付宝订单支付状态结果](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=ap2021001172656340://`
|
||||||
|
Alipay.alipay(payInfo, (res)=>console.log(res))
|
||||||
|
```
|
||||||
|
|
||||||
|
3. 用的 `URL Schemes` 列为白名单,在 [`ios/<应用名称>/Info.plist`](https://github.com/uiwjs/react-native-uiwjs-alipay/blob/866888a3ed9f05d06fa9a7ed93922d9ca2dcc56e/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>ap2021001172656340</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 ap2021001172656340://`
|
||||||
|
|
||||||
|
## 错误处理
|
||||||
|
|
||||||
|
```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) 初始化。
|
当前工程基于 [@brodybits/create-react-native-module](https://github.com/brodybits/create-react-native-module) 初始化。
|
||||||
|
|
||||||
@@ -54,8 +126,8 @@ 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"
|
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)
|
- [支付宝生成秘钥指南](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)
|
||||||
|
- [React-native 0.6版本集成支付宝-Alipay爬坑](https://segmentfault.com/a/1190000020758279)
|
||||||
|
@@ -1,15 +1,32 @@
|
|||||||
import React, { Component } from 'react';
|
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';
|
import Alipay from 'react-native-uiwjs-alipay';
|
||||||
|
|
||||||
export default class App extends Component {
|
export default class App extends Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
Alipay.setAlipayScheme('ap2021001172656340');
|
Alipay.setAlipayScheme('ap2021001172656340');
|
||||||
|
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 = () => {
|
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¬ify_url=http%3A%2F%2Fdomain.merchant.com%2Fpayment_notify&sign_type=RSA2×tamp=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%22123123213123217%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¬ify_url=http%3A%2F%2Fane.boshu.ltd%2Fowner%2Fpay%2Fapi%2FownerPay%2Fcallback&return_url=ap2021001172656340%3A%2F%2F&sign=NVSGkwXj%2BA2FATt%2BHXrzt%2B6WdalIt8JhBpTIXQRRvtkdzP0ZC85si2jK27rM5DWzrWfF9KOuA1Mk0%2BkT3P6NRKEYL4%2FDS5VlZf6BSta8CTcZIgGAnQr8H8dKCWxkzQtvUbLBCimQpJyesidmxh3tXNZNHZHcjonJeqmu%2FdSv%2BubruAfo3etNUwGJQscPGbLtCy%2BU%2BEihSmNPVTIjh56MJunF%2Fu1I%2Fbte85XCzfJVrgGnWtvpT%2BRcbdDrDkRDc3JuRHbNsRgY%2FY413ovI5xSnGZ1oWLAd%2ByXuqoT0zDL8O%2FDu38nSJU%2Bkm1SF0u6Gpkvajef4%2F6WglfCMrqZCet%2B7GA%3D%3D&sign_type=RSA2×tamp=2020-07-08+21%3A45%3A27&version=1.0`;
|
||||||
Alipay.alipay(payInfo, (resule) => {
|
Alipay.alipay(payInfo, (resule) => {
|
||||||
console.log(resule)
|
console.log('resule-->>>', resule)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
|
@@ -681,7 +681,7 @@
|
|||||||
"-ObjC",
|
"-ObjC",
|
||||||
"-lc++",
|
"-lc++",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
|
PRODUCT_BUNDLE_IDENTIFIER = com.uiwjs;
|
||||||
PRODUCT_NAME = example;
|
PRODUCT_NAME = example;
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
@@ -704,7 +704,7 @@
|
|||||||
"-ObjC",
|
"-ObjC",
|
||||||
"-lc++",
|
"-lc++",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
|
PRODUCT_BUNDLE_IDENTIFIER = com.uiwjs;
|
||||||
PRODUCT_NAME = example;
|
PRODUCT_NAME = example;
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
@@ -60,6 +60,13 @@
|
|||||||
ReferencedContainer = "container:example.xcodeproj">
|
ReferencedContainer = "container:example.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</BuildableProductRunnable>
|
</BuildableProductRunnable>
|
||||||
|
<EnvironmentVariables>
|
||||||
|
<EnvironmentVariable
|
||||||
|
key = "OS_ACTIVITY_MODE"
|
||||||
|
value = "disable"
|
||||||
|
isEnabled = "YES">
|
||||||
|
</EnvironmentVariable>
|
||||||
|
</EnvironmentVariables>
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
<ProfileAction
|
<ProfileAction
|
||||||
buildConfiguration = "Release"
|
buildConfiguration = "Release"
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
#import <React/RCTBridge.h>
|
#import <React/RCTBridge.h>
|
||||||
#import <React/RCTBundleURLProvider.h>
|
#import <React/RCTBundleURLProvider.h>
|
||||||
#import <React/RCTRootView.h>
|
#import <React/RCTRootView.h>
|
||||||
|
#import <React/RCTLinkingManager.h>
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
#import <FlipperKit/FlipperClient.h>
|
#import <FlipperKit/FlipperClient.h>
|
||||||
@@ -55,4 +56,16 @@ static void InitializeFlipper(UIApplication *application) {
|
|||||||
#endif
|
#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
|
@end
|
||||||
|
@@ -26,17 +26,21 @@
|
|||||||
<key>CFBundleTypeRole</key>
|
<key>CFBundleTypeRole</key>
|
||||||
<string>Editor</string>
|
<string>Editor</string>
|
||||||
<key>CFBundleURLName</key>
|
<key>CFBundleURLName</key>
|
||||||
<string>I</string>
|
<string></string>
|
||||||
|
<key>CFBundleURLSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>ap2021001172656340</string>
|
||||||
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1</string>
|
<string>1</string>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
|
||||||
<true/>
|
|
||||||
<key>LSApplicationQueriesSchemes</key>
|
<key>LSApplicationQueriesSchemes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>alipay</string>
|
<string>alipay</string>
|
||||||
</array>
|
</array>
|
||||||
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
<true/>
|
||||||
<key>NSAppTransportSecurity</key>
|
<key>NSAppTransportSecurity</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSAllowsArbitraryLoads</key>
|
<key>NSAllowsArbitraryLoads</key>
|
||||||
|
113
index.d.ts
vendored
113
index.d.ts
vendored
@@ -4,51 +4,90 @@
|
|||||||
* 支付宝回调结果, 详情见 https://docs.open.alipay.com/204/105301
|
* 支付宝回调结果, 详情见 https://docs.open.alipay.com/204/105301
|
||||||
*/
|
*/
|
||||||
export interface AliOrderResult {
|
export interface AliOrderResult {
|
||||||
/**
|
alipay_trade_app_pay_response: {
|
||||||
* 长度:64,商户网站唯一订单号 70501111111S001111119
|
/**
|
||||||
*/
|
* 长度:64,商户网站唯一订单号 70501111111S001111119
|
||||||
out_trade_no: string;
|
*/
|
||||||
/**
|
out_trade_no: string;
|
||||||
* 长度:64,该交易在支付宝系统中的交易流水号。最长64位。 2014112400001000340011111118
|
/**
|
||||||
*/
|
* 长度:64,该交易在支付宝系统中的交易流水号。最长64位。 2014112400001000340011111118
|
||||||
trade_no: string;
|
*/
|
||||||
/**
|
trade_no: string;
|
||||||
* 长度:32,支付宝分配给开发者的应用Id。 2014072300007148
|
/**
|
||||||
*/
|
* 长度:32,支付宝分配给开发者的应用Id。 2014072300007148
|
||||||
app_id: string;
|
*/
|
||||||
/**
|
app_id: string;
|
||||||
* 长度:9 ,该笔订单的资金总额,单位为RMB-Yuan。取值范围为[0.01,100000000.00],精确到小数点后两位。 9.00
|
/**
|
||||||
*/
|
* 长度:9 ,该笔订单的资金总额,单位为RMB-Yuan。取值范围为[0.01,100000000.00],精确到小数点后两位。 9.00
|
||||||
total_amount: number;
|
*/
|
||||||
/**
|
total_amount: number;
|
||||||
* 长度:16,收款支付宝账号对应的支付宝唯一用户号。以2088开头的纯16位数字 20886894
|
/**
|
||||||
*/
|
* 长度:16,收款支付宝账号对应的支付宝唯一用户号。以2088开头的纯16位数字 20886894
|
||||||
seller_id: string;
|
*/
|
||||||
/**
|
seller_id: string;
|
||||||
* 长度:16,处理结果的描述,信息来自于code返回结果的描述 success
|
/**
|
||||||
*/
|
* 长度:16,处理结果的描述,信息来自于code返回结果的描述 success
|
||||||
msg: string;
|
*/
|
||||||
/**
|
msg: string;
|
||||||
* 长度:16,编码格式 utf-8
|
/**
|
||||||
*/
|
* 长度:16,编码格式 utf-8
|
||||||
charset: string;
|
*/
|
||||||
/**
|
charset: string;
|
||||||
* 长度:32,时间 2016-10-11 17:43:36
|
/**
|
||||||
*/
|
* 长度:32,时间 2016-10-11 17:43:36
|
||||||
timestamp: string;
|
*/
|
||||||
/**
|
timestamp: string;
|
||||||
* 长度:16,结果码 具体见公共错误码
|
/**
|
||||||
*/
|
* 长度:16,结果码 具体见公共错误码
|
||||||
code: string;
|
*/
|
||||||
|
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: {
|
export const Alipay: {
|
||||||
/**
|
/**
|
||||||
* @param payInfo 支付详情
|
* @param payInfo 支付详情
|
||||||
* @param result 支付宝回调结果
|
* @param result 支付宝回调结果
|
||||||
*/
|
*/
|
||||||
alipay: (payInfo: string, callback?: (result: AliOrderResult) => void) => void;
|
alipay: (payInfo: string, callback?: (result: Resule) => void) => void;
|
||||||
/**
|
/**
|
||||||
* 设置支付宝跳转Scheme,仅 iOS
|
* 设置支付宝跳转Scheme,仅 iOS
|
||||||
* @param scheme scheme = `ap` + `APPID`
|
* @param scheme scheme = `ap` + `APPID`
|
||||||
|
@@ -34,12 +34,12 @@ RCT_EXPORT_MODULE()
|
|||||||
self->alipayCallBack([[NSArray alloc] initWithObjects:resultDic, nil]);
|
self->alipayCallBack([[NSArray alloc] initWithObjects:resultDic, nil]);
|
||||||
self->alipayCallBack = nil;
|
self->alipayCallBack = nil;
|
||||||
}
|
}
|
||||||
NSLog(@"result = %@",resultDic);
|
NSLog(@"result-->1 = %@",resultDic);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
// 授权跳转支付宝钱包进行支付,处理支付结果
|
// 授权跳转支付宝钱包进行支付,处理支付结果
|
||||||
[[AlipaySDK defaultService] processAuth_V2Result:aURL standbyCallback:^(NSDictionary *resultDic) {
|
[[AlipaySDK defaultService] processAuth_V2Result:aURL standbyCallback:^(NSDictionary *resultDic) {
|
||||||
NSLog(@"result = %@",resultDic);
|
NSLog(@"result-->2 = %@", resultDic);
|
||||||
// 解析 auth code
|
// 解析 auth code
|
||||||
NSString *result = resultDic[@"result"];
|
NSString *result = resultDic[@"result"];
|
||||||
NSString *authCode = nil;
|
NSString *authCode = nil;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-uiwjs-alipay",
|
"name": "react-native-uiwjs-alipay",
|
||||||
"version": "1.0.1",
|
"version": "1.1.0",
|
||||||
"description": "基于 React Native 的宝支付插件",
|
"description": "基于 React Native 的宝支付插件",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
5
renovate.json
Normal file
5
renovate.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"config:base"
|
||||||
|
]
|
||||||
|
}
|
Reference in New Issue
Block a user