@@ -21,7 +21,7 @@
## 安装依赖
```bash
yarn add react-native-uiwjs- alipay
yarn add @uiw/ react-native-alipay
# react-native version >= 0.60+
$ cd ios && pod install
```
@@ -32,7 +32,7 @@ $ cd ios && pod install
> `Alipay.alipay: (payInfo: string) => Promise<OrderResult>;`
- ⚠️ 注意支付成功返回结果是一个字符串,[返回内容 ](https://github.com/uiwjs/react-native-alipay/blob/05b4dc3d87ea309b6b6153690fa ee508cd23e2bf /index.d.ts#L50-L74 )
- ⚠️ 注意支付成功返回结果是一个字符串,[返回内容 ](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00 ee7 5003 /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 )
@@ -70,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-alipay/blob/05b4dc3d87ea309b6b6153690fa ee508cd23e2bf /index.d.ts#L50-L74 ):
支付返回结果,支付宝[返回结果参数说明 ](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00 ee7 5003 /index.d.ts#L50-L74 ):
```json
{
@@ -84,7 +84,7 @@ alipay_sdk=alipay-sdk-java-dynamicVersionNo&app_id=xxxxxxxxxxxxx&biz_content=%7B
> `Alipay.authInfo: (authInfoStr: string) => Promise<AuthResult>`;
- ⚠️ 注意授权成功返回结果是一个字符串,[返回内容 ](https://github.com/uiwjs/react-native-alipay/blob/05b4dc3d87ea309b6b6153690fa ee508cd23e2bf /index.d.ts#L89-L113 )
- ⚠️ 注意授权成功返回结果是一个字符串,[返回内容 ](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00 ee7 5003 /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 )
@@ -105,7 +105,7 @@ async function authInfo() {
}
```
授权返回结果,支付宝[返回结果参数说明 ](https://github.com/uiwjs/react-native-alipay/blob/05b4dc3d87ea309b6b6153690fa ee508cd23e2bf /index.d.ts#L89-L113 ):
授权返回结果,支付宝[返回结果参数说明 ](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00 ee7 5003 /index.d.ts#L89-L113 ):
```json
{
@@ -133,20 +133,20 @@ async function getVersion() {
- ⚠️ Android 端不需要做任何设置。
- ⚠️ 如果用户从 `支付宝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-alipay/blob/05b4dc3d87ea309b6b6153690fa ee508cd23e2bf /example/App.js#L7 ),下面实例 [`uiwjspay` ](https://github.com/uiwjs/react-native-alipay/commit/f6d21b6b7ec7236b195c56281f971092f3c9bb08 ) 是定义的 `scheme` ,你也可以定义为 `alipay` + `appid` , `appid` 为支付宝分配给开发者的应用ID, 用来表述 `scheme` 唯一性。
1. 在代码中设置支付宝 [`URL Schemes` ](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00 ee7 5003 /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-alipay/blob/05b4dc3d87ea309b6b6153690fa ee508cd23e2bf /example/App.js#L11 ) 中必须包含 [`return_url=uiwjspay://` ](https://github.com/uiwjs/react-native-alipay/blob/05b4dc3d87ea309b6b6153690fa ee508cd23e2bf /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 )
2. 在请求支付的 [`payInfo` ](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00 ee7 5003 /example/App.js#L11 ) 中必须包含 [`return_url=uiwjspay://` ](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00 ee7 5003 /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-alipay/blob/05b4dc3d87ea309b6b6153690fa ee508cd23e2bf /example/ios/example/Info.plist#L23-L41 ) 中添加
3. 用的 `URL Schemes` 列为白名单,在 [`ios/<应用名称>/Info.plist` ](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00 ee7 5003 /example/ios/example/Info.plist#L23-L41 ) 中添加
```xml
<key> LSApplicationQueriesSchemes</key>
@@ -168,7 +168,7 @@ Alipay.alipay(payInfo, (res)=>console.log(res))
</array>
```
4. 修改 [`ios/<应用名称>/AppDelegate.m` ](https://github.com/uiwjs/react-native-alipay/blob/05b4dc3d87ea309b6b6153690fa ee508cd23e2bf /example/ios/example/AppDelegate.m#L60-L70 ) 添加下列代码:
4. 修改 [`ios/<应用名称>/AppDelegate.m` ](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00 ee7 5003 /example/ios/example/AppDelegate.m#L60-L70 ) 添加下列代码:
```objective-c
#import <React/RCTLinkingManager.h>