├── .editorconfig ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .npmignore ├── .yarnrc ├── LICENSE ├── README.md ├── android ├── README.md ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── uiwjs │ │ ├── RNAlipayModule.java │ │ └── RNAlipayPackage.java │ └── res │ └── values │ └── strings.xml ├── example ├── .buckconfig ├── .eslintrc.js ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .prettierrc.js ├── .ruby-version ├── .watchmanconfig ├── App.js ├── Gemfile ├── __tests__ │ └── App-test.js ├── android │ ├── app │ │ ├── _BUCK │ │ ├── build.gradle │ │ ├── build_defs.bzl │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ ├── MainActivity.java │ │ │ │ ├── MainApplication.java │ │ │ │ └── newarchitecture │ │ │ │ ├── MainApplicationReactNativeHost.java │ │ │ │ ├── components │ │ │ │ └── MainComponentsRegistry.java │ │ │ │ └── modules │ │ │ │ └── MainApplicationTurboModuleManagerDelegate.java │ │ │ ├── jni │ │ │ ├── Android.mk │ │ │ ├── MainApplicationModuleProvider.cpp │ │ │ ├── MainApplicationModuleProvider.h │ │ │ ├── MainApplicationTurboModuleManagerDelegate.cpp │ │ │ ├── MainApplicationTurboModuleManagerDelegate.h │ │ │ ├── MainComponentsRegistry.cpp │ │ │ ├── MainComponentsRegistry.h │ │ │ └── OnLoad.cpp │ │ │ └── res │ │ │ ├── drawable │ │ │ └── rn_edit_text_material.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── ios │ ├── Podfile │ ├── Podfile.lock │ ├── _xcode.env │ ├── example.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── example.xcscheme │ ├── example.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── example │ │ ├── AppDelegate.h │ │ ├── AppDelegate.mm │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ └── main.m │ └── exampleTests │ │ ├── Info.plist │ │ └── exampleTests.m ├── metro.config.js ├── package.json └── react-native.config.js ├── index.d.ts ├── index.js ├── ios ├── AlipaySDK.bundle │ ├── alipay_msp_back@2x.png │ ├── alipay_msp_refresh@2x.png │ ├── bar@2x.png │ ├── bridge.js │ ├── refresh@2x.png │ ├── refresh_click@2x.png │ ├── shutdown@2x.png │ └── shutdown_click@2x.png ├── AlipaySDK.framework │ ├── AlipaySDK │ ├── AlipaySDK-inside-Info.plist │ └── Headers │ │ ├── AFServiceCenter.h │ │ ├── AFServiceResponse.h │ │ ├── APayAuthInfo.h │ │ └── AlipaySDK.h ├── RNAlipay.h ├── RNAlipay.m ├── RNAlipay.xcodeproj │ └── project.pbxproj └── RNAlipay.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── package.json ├── react-native-alipay.podspec ├── renovate.json ├── scripts └── bootstrap.js └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # Windows files 2 | [*.bat] 3 | end_of_line = crlf -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Build and Deploy Documents 2 | on: 3 | push: 4 | branches: 5 | - master 6 | 7 | jobs: 8 | build-deploy: 9 | runs-on: ubuntu-18.04 10 | steps: 11 | - uses: actions/checkout@master 12 | 13 | - name: Setup Node 14 | uses: actions/setup-node@v1 15 | with: 16 | node-version: 10 17 | 18 | - run: npm install 19 | - run: npm run build 20 | 21 | - name: Create Tag 22 | id: create_tag 23 | uses: jaywcjlove/create-tag-action@v1.3.5 24 | with: 25 | package-path: ./package.json 26 | 27 | - name: Generate Changelog 28 | id: changelog 29 | uses: jaywcjlove/changelog-generator@v1.4.8 30 | with: 31 | token: ${{ secrets.GITHUB_TOKEN }} 32 | head-ref: ${{steps.create_tag.outputs.version}} 33 | filter-author: (renovate-bot|Renovate Bot) 34 | filter: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}' 35 | 36 | - name: Build and Deploy 37 | uses: peaceiris/actions-gh-pages@v3 38 | with: 39 | github_token: ${{ secrets.GITHUB_TOKEN }} 40 | publish_dir: ./typedoc 41 | 42 | - name: Create Release 43 | uses: jaywcjlove/create-tag-action@v1.3.5 44 | with: 45 | package-path: ./package.json 46 | release: true 47 | body: | 48 | [![](https://img.shields.io/badge/Open%20in-unpkg-blue)](https://uiwjs.github.io/npm-unpkg/#/pkg/@uiw/react-native-alipay@${{steps.changelog.outputs.version}}/file/README.md) 49 | 50 | ${{ steps.changelog.outputs.compareurl }} 51 | 52 | ${{ steps.changelog.outputs.changelog }} 53 | 54 | ```bash 55 | npm i @uiw/react-native-alipay@${{steps.changelog.outputs.version}} 56 | ``` 57 | 58 | - name: 📦 @uiw/react-native-alipay publish to NPM 59 | uses: JS-DevTools/npm-publish@v1 60 | with: 61 | token: ${{ secrets.NPM_TOKEN }} 62 | package: ./package.json 63 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # node.js 6 | # 7 | typedoc 8 | node_modules/ 9 | npm-debug.log 10 | yarn-error.log 11 | yarn.lock 12 | 13 | # Xcode 14 | # 15 | build/ 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | xcuserdata 25 | *.xccheckout 26 | *.moved-aside 27 | DerivedData 28 | *.hmap 29 | *.ipa 30 | *.xcuserstate 31 | project.xcworkspace 32 | 33 | # Android/IntelliJ 34 | # 35 | build/ 36 | .idea 37 | .gradle 38 | local.properties 39 | *.iml 40 | 41 | # BUCK 42 | buck-out/ 43 | \.buckd/ 44 | *.keystore 45 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # JS 2 | node_modules 3 | yarn.lock 4 | 5 | # Config files 6 | renovate.json 7 | 8 | # Example 9 | example/ 10 | 11 | # Android 12 | android/*/build/ 13 | android/gradlew 14 | android/build 15 | android/gradlew.bat 16 | android/gradle/ 17 | android/com_crashlytics_export_strings.xml 18 | android/local.properties 19 | android/.gradle/ 20 | android/.signing/ 21 | android/.idea/gradle.xml 22 | android/.idea/libraries/ 23 | android/.idea/workspace.xml 24 | android/.idea/tasks.xml 25 | android/.idea/.name 26 | android/.idea/compiler.xml 27 | android/.idea/copyright/profiles_settings.xml 28 | android/.idea/encodings.xml 29 | android/.idea/misc.xml 30 | android/.idea/modules.xml 31 | android/.idea/scopes/scope_settings.xml 32 | android/.idea/vcs.xml 33 | android/*.iml 34 | android/.settings 35 | 36 | # iOS 37 | ios/*.xcodeproj/xcuserdata 38 | *.pbxuser 39 | *.mode1v3 40 | *.mode2v3 41 | *.perspectivev3 42 | *.xcuserstate 43 | project.xcworkspace/ 44 | xcuserdata/ 45 | ios/build/ 46 | 47 | # Misc 48 | .DS_Store 49 | .DS_Store? 50 | coverage.android.json 51 | coverage.ios.json 52 | npm-debug.log 53 | .github 54 | ._* 55 | .Spotlight-V100 56 | .Trashes 57 | ehthumbs.db 58 | Thumbs.dbandroid/gradle 59 | docs 60 | .idea 61 | bin/test.js 62 | codorials 63 | website/ -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | # Override Yarn command so we can automatically setup the repo on running `yarn` 2 | 3 | yarn-path "scripts/bootstrap.js" 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 uiw 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | 5 |

@uiw/react-native-alipay

6 |

7 | 8 | 9 | [![NPM Version](https://img.shields.io/npm/v/@uiw/react-native-alipay.svg)](https://npmjs.org/package/@uiw/react-native-alipay) 10 | ![David](https://img.shields.io/david/peer/uiwjs/react-native-alipay) 11 | 12 | 基于 React Native 的宝支付插件,支持 iOS/Android。适用于商家在 App 应用中集成支付宝支付功能,商家 APP 调用支付宝提供的 SDK,SDK 再调用支付宝 APP 内的支付模块。如果用户已安装支付宝APP,商家APP会跳转到支付宝中完成支付,支付完后跳回到商家 APP 内,最后展示支付结果。如果用户没有安装支付宝 APP,商家 APP 内会调起支付宝网页支付收银台,用户登录支付宝账户,支付完后展示支付结果。完整实例 [Example](./example) | [完整的接口文档](https://uiwjs.github.io/react-native-alipay/) 13 | 14 | ![](https://gw.alipayobjects.com/zos/skylark-tools/public/files/c0aa8379f5f57c55f1e5bf25e6f426d1.png) 15 | 16 | ![](https://gw.alipayobjects.com/zos/skylark-tools/public/files/2454bffde14f428b2eeb2bfb6aa28d6b.png) 17 | 18 | > ⚠️ `4.0+` 在 iOS 打包中报错,这是因为[使用阿里云产品的 SDK 出现 UTDID 冲突的问题](https://help.aliyun.com/document_detail/39984.html),在 [@EatherToo](https://github.com/EatherToo) 的帮助下([#44](https://github.com/uiwjs/react-native-alipay/pull/44)),UTDID 被剥离了。可以在 `Podfile` 中加上 `pod 'UTDID'` 解决打包失败的问题。感谢 [@abing](https://github.com/ouabing) 19 | 20 | > ⚠️ `v5.x` 在 android 需要 `Gradle 7+` ([#61](https://github.com/uiwjs/react-native-alipay/issues/61#issuecomment-1206243613) [#60](https://github.com/uiwjs/react-native-alipay/pull/60)) 21 | 22 | ## 注意事项 23 | 24 | 1. Android:支持2.3及以上的系统版本运行。 25 | 2. iOS:iOS 6.0以上(包含iOS 6.0)。 26 | 3. 支持手机系统:iOS(苹果)、Android(安卓)。 27 | 4. 调试请注意 支付宝接入应用必须 `已审核通过` 状态。 28 | 5. 支付宝开放平台-管理中心,签约 `APP支付` 和 `APP支付宝登录` 功能。 29 | 6. 适用于 `react-native >= 0.60+` 低版本未测试。 30 | 7. AlipaySDK 15.7.7 已更新到最新的支付宝 SDK 版本。 31 | 8. `URL Schemes` 要以字母开头不能为纯数字。 32 | 33 | ## 安装依赖 34 | 35 | ```bash 36 | yarn add @uiw/react-native-alipay 37 | # react-native version >= 0.60+ 38 | $ cd ios && pod install 39 | ``` 40 | 41 | ## API 42 | 43 | ### `Alipay.alipay` 支付 44 | 45 | > `Alipay.alipay: (payInfo: string) => Promise;` 46 | 47 | - ⚠️ 注意支付成功返回结果是一个字符串,[返回内容](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/index.d.ts#L50-L74) 48 | - ⚠️ 支付宝需要设置 `Scheme` 和 iOS添加原生代码,才能支持支付和[回弹商家APP](#支付宝返回应用-ios-设置)的功能 49 | - ⚠️ 支付宝 `管理中心-支付宝开放平台` 需要签约 [`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) 50 | 51 | ```javascript 52 | import Alipay from '@uiw/react-native-alipay'; 53 | 54 | // 设置 支付宝 URL Schemes,要表述他是宇宙唯一性,可以使用 `bundle Identifier` 55 | // scheme = `alipay` + `APPID`,`APPID` 为支付宝分配给开发者的应用ID 56 | Alipay.setAlipayScheme(scheme); 57 | // ⚠️ 目前不可用,设置支付宝沙箱环境,仅 Android 支持 58 | // Alipay.setAlipaySandbox(isSandbox); 59 | 60 | async function aliPay() { 61 | // 支付宝端支付 62 | // payInfo 是后台拼接好的支付参数 63 | // return_url= 64 | 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¬ify_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×tamp=2020-07-09+12%3A16%3A16&version=1.0'; 65 | const resule = await Alipay.alipay(payInfo); 66 | console.log('alipay:resule-->>>', resule); 67 | } 68 | ``` 69 | 70 | 订单详情 [`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) 编码前的数据 71 | 72 | ```bash 73 | 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¬ify_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×tamp=2020-07-09 09:50:41&version=1.0 74 | ``` 75 | 76 | 订单详情 `payInfo` 编码的数据 77 | 78 | ```bash 79 | 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¬ify_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×tamp=2020-07-09+09%3A50%3A41&version=1.0 80 | ``` 81 | 82 | - ⚠️ 后台 SDK 根据所有数据生成 `sign`,建议通过 API 拿到这个数据,拼接数据会报错。 83 | - ⚠️ `out_trade_no` 订单 id 和 `sign` 签名 是唯一的,每次不一样,需要后台生成。 84 | 85 | 支付返回结果,支付宝[返回结果参数说明](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/index.d.ts#L50-L74): 86 | 87 | ```json 88 | { 89 | "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\"}", 90 | "resultStatus": "9000", 91 | "memo": "" 92 | } 93 | ``` 94 | 95 | ### `Alipay.authInfo` 登录授权 96 | 97 | > `Alipay.authInfo: (authInfoStr: string) => Promise`; 98 | 99 | - ⚠️ 注意授权成功返回结果是一个字符串,[返回内容](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/index.d.ts#L89-L113) 100 | - ⚠️ 支付宝需要设置 `Scheme` 和 iOS添加原生代码,才能支持验证[回弹商家APP](#支付宝返回应用-ios-设置)的功能 101 | - ⚠️ 支付宝 `管理中心-支付宝开放平台` 需要签约 [`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) 102 | 103 | ```javascript 104 | import Alipay from '@uiw/react-native-alipay'; 105 | 106 | // 设置 支付宝 URL Schemes,要表述他是宇宙唯一性,可以使用 `bundle Identifier` 107 | // scheme = `alipay` + `APPID`,`APPID` 为支付宝分配给开发者的应用ID 108 | Alipay.setAlipayScheme(scheme); 109 | 110 | async function authInfo() { 111 | // 支付宝端授权验证 112 | // authInfoStr 是后台拼接好的验证参数 113 | 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'; 114 | const resule = await Alipay.authInfo(authInfoStr); 115 | // resule => success=true&auth_code=9c11732de44f4f1790b63978b6fbOX53&result_code=200&alipay_open_id=20881001757376426161095132517425&user_id=2088003646494707 116 | console.log('authInfo:resule-->>>', resule); 117 | } 118 | ``` 119 | 120 | 授权返回结果,支付宝[返回结果参数说明](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/index.d.ts#L89-L113): 121 | 122 | ```json 123 | { 124 | "resultStatus": "9000", 125 | "memo": "处理成功", 126 | "result": "success=true&result_code=200&app_id=202100117265&auth_code=8b6e5581b85WX84&scope=kuaijie&alipay_open_id=20881029919664670&user_id=20880025&target_id=15946456110003465" 127 | } 128 | ``` 129 | 130 | ### `Alipay.getVersion` 获取 SDK 版本 131 | 132 | > `Alipay.getVersion: () => Promise;` 133 | 134 | ```js 135 | import Alipay from '@uiw/react-native-alipay'; 136 | 137 | async function getVersion() { 138 | const version = await Alipay.getVersion(); 139 | console.log('version:', version); 140 | } 141 | ``` 142 | 143 | ## 支付宝返回应用 iOS 设置 144 | 145 | - ⚠️ Android 端不需要做任何设置。 146 | - ⚠️ 如果用户从 `支付宝App` 跳转到 `商家APP`,是通过系统功能切换,而不是通过 `支付宝APP` 功能键返回 `商家APP`,回调函数是不起作用的,可通过 [`AppState.addEventListener`](https://github.com/uiwjs/react-native-alipay/blob/5daea87bf0af05d60d0ae9e4c04e1e2d1a6e4273/example/App.js#L8-L24) 监听事件请求后台 API,来优化这一用户体验。 147 | 148 | 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` 唯一性。 149 | 150 | ```js 151 | Alipay.setAlipayScheme('uiwjspay'); 152 | ``` 153 | 154 | 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) 155 | 156 | ```js 157 | // payInfo 是后台拼接好的支付参数,这个参数必须包含 `return_url=uiwjspay://` 158 | Alipay.alipay(payInfo, (res)=>console.log(res)) 159 | ``` 160 | 161 | 3. 用的 `URL Schemes` 列为白名单,在 [`ios/<应用名称>/Info.plist`](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/example/ios/example/Info.plist#L23-L41) 中添加 162 | 163 | ```xml 164 | LSApplicationQueriesSchemes 165 | 166 | alipay 167 | 168 | CFBundleURLTypes 169 | 170 | 171 | CFBundleTypeRole 172 | Editor 173 | CFBundleURLName 174 | 175 | CFBundleURLSchemes 176 | 177 | uiwjspay 178 | 179 | 180 | 181 | ``` 182 | 183 | 4. 修改 [`ios/<应用名称>/AppDelegate.m`](https://github.com/uiwjs/react-native-alipay/blob/74140a294e850884ed1851b9d2c2d2c00ee75003/example/ios/example/AppDelegate.m#L60-L70) 添加下列代码: 184 | 185 | ```objective-c 186 | #import 187 | 188 | - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation 189 | { 190 | return [RCTLinkingManager application:application openURL:url 191 | sourceApplication:sourceApplication annotation:annotation]; 192 | } 193 | 194 | - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options 195 | { 196 | return [RCTLinkingManager application:application openURL:url options:options]; 197 | } 198 | ``` 199 | 200 | **命令测试** 201 | 202 | - iOS: `xcrun simctl openurl booted uiwjspay://` 203 | - Android:`adb shell am start -W -a android.intent.action.VIEW -d "uiwjspay://test/router" com.uiwjspay` 204 | 205 | ## 错误处理 206 | 207 | ```bash 208 | [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: 209 | ``` 210 | 211 | 在 `Product` -> `Scheme` -> `Edit Scheme` -> `Run` -> `Arguments` -> `Environment Variables` 添加 `OS_ACTIVITY_MODE` `disable` 212 | 213 | ## 其它 214 | 215 | 当前工程基于 [@brodybits/create-react-native-module](https://github.com/brodybits/create-react-native-module) 初始化。 216 | 217 | ```bash 218 | npx create-react-native-module --package-identifier com.uiwjs --object-class-name RNAlipay --generate-example Alipay --example-react-native-version 0.63.0 --module-name @uiw/react-native-alipay --github-account uiwjs --author-name "Kenny Wong" --author-email "wowohoo@qq.com" 219 | ``` 220 | 221 | ## 开发 222 | 223 | ```bash 224 | cd example # 进入实例 example 工程,根目录不需要安装,会引发错误 225 | yarn install # 安装依赖 226 | 227 | cd ios # 进入 example/ios 目录安装依赖 228 | pod instll # 安装依赖 229 | ``` 230 | 231 | ## 相关连接 232 | 233 | - [支付宝:生成秘钥指南](https://opendocs.alipay.com/open/291/105971) 234 | - [支付宝:SDK 下载地址,当前使用的是 AlipaySDK 15.8.03](https://opendocs.alipay.com/open/54/104509) 235 | - [支付宝:客户端调试工具及使用教程](https://openclub.alipay.com/club/history/read/7695) 236 | - [支付宝:支付,接入前准备](https://opendocs.alipay.com/open/204/105297/) 237 | - [支付宝:完整版授权 SDK 调用方法](https://opendocs.alipay.com/open/218/105325) 238 | - [支付宝:异步通知错误码: IllRet](https://opensupport.alipay.com/support/problem.htm?ant_source=antsupport) 239 | - [@uiw/react-native-wechat](https://github.com/uiwjs/react-native-wechat) 微信支付。 240 | -------------------------------------------------------------------------------- /android/README.md: -------------------------------------------------------------------------------- 1 | README 2 | ====== 3 | 4 | If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm: 5 | 6 | 1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed 7 | 2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK 8 | ``` 9 | ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle 10 | sdk.dir=/Users/{username}/Library/Android/sdk 11 | ``` 12 | 3. Delete the `maven` folder 13 | 4. Run `./gradlew installArchives` 14 | 5. Verify that latest set of generated files is in the maven folder with the correct version number 15 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // android/build.gradle 2 | 3 | // based on: 4 | // 5 | // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle 6 | // original location: 7 | // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle 8 | // 9 | // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle 10 | // original location: 11 | // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle 12 | 13 | def DEFAULT_COMPILE_SDK_VERSION = 29 14 | def DEFAULT_BUILD_TOOLS_VERSION = '29.0.3' 15 | def DEFAULT_MIN_SDK_VERSION = 16 16 | def DEFAULT_TARGET_SDK_VERSION = 29 17 | 18 | def safeExtGet(prop, fallback) { 19 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback 20 | } 21 | 22 | apply plugin: 'com.android.library' 23 | apply plugin: 'maven-publish' 24 | 25 | buildscript { 26 | // The Android Gradle plugin is only required when opening the android folder stand-alone. 27 | // This avoids unnecessary downloads and potential conflicts when the library is included as a 28 | // module dependency in an application project. 29 | // ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies 30 | if (project == rootProject) { 31 | repositories { 32 | google() 33 | jcenter() 34 | } 35 | dependencies { 36 | classpath("com.android.tools.build:gradle:4.1.0") 37 | } 38 | } 39 | } 40 | 41 | android { 42 | compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) 43 | buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION) 44 | defaultConfig { 45 | minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION) 46 | targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION) 47 | versionCode 1 48 | versionName "1.0" 49 | } 50 | lintOptions { 51 | abortOnError false 52 | } 53 | } 54 | 55 | repositories { 56 | // ref: https://www.baeldung.com/maven-local-repository 57 | mavenLocal() 58 | maven { 59 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 60 | url "$rootDir/../node_modules/react-native/android" 61 | } 62 | maven { 63 | // Android JSC is installed from npm 64 | url "$rootDir/../node_modules/jsc-android/dist" 65 | } 66 | google() 67 | jcenter() 68 | } 69 | 70 | dependencies { 71 | //noinspection GradleDynamicVersion 72 | implementation 'com.facebook.react:react-native:+' // From node_modules 73 | 74 | // 支付宝 SDK AAR 包所需的配置 75 | implementation 'com.alipay.sdk:alipaysdk-android:15.8.10@aar' 76 | implementation fileTree(dir: "libs", include: ["*.aar"]) 77 | } 78 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/src/main/java/com/uiwjs/RNAlipayModule.java: -------------------------------------------------------------------------------- 1 | package com.uiwjs.alipay; 2 | 3 | import com.alipay.sdk.app.AuthTask; 4 | import com.alipay.sdk.app.PayTask; 5 | import com.alipay.sdk.app.EnvUtils; 6 | import com.facebook.react.bridge.Arguments; 7 | import com.facebook.react.bridge.ReactApplicationContext; 8 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 9 | import com.facebook.react.bridge.ReactMethod; 10 | import com.facebook.react.bridge.ReadableMap; 11 | import com.facebook.react.bridge.WritableMap; 12 | import com.facebook.react.bridge.Promise; 13 | // import com.facebook.react.bridge.Callback; 14 | 15 | import java.util.Map; 16 | 17 | public class RNAlipayModule extends ReactContextBaseJavaModule { 18 | 19 | private final ReactApplicationContext reactContext; 20 | 21 | public RNAlipayModule(ReactApplicationContext reactContext) { 22 | super(reactContext); 23 | this.reactContext = reactContext; 24 | } 25 | 26 | @Override 27 | public String getName() { 28 | return "RNAlipay"; 29 | } 30 | 31 | // @ReactMethod 32 | // public void sampleMethod(String stringArgument, int numberArgument, Callback callback) { 33 | // // TODO: Implement some actually useful functionality 34 | // callback.invoke("Received numberArgument: " + numberArgument + " stringArgument: " + stringArgument); 35 | // } 36 | 37 | @ReactMethod 38 | public void authInfo(final String infoStr, final Promise promise) { 39 | Runnable runnable = new Runnable() { 40 | @Override 41 | public void run() { 42 | AuthTask authTask = new AuthTask(getCurrentActivity()); 43 | Map map = authTask.authV2(infoStr, true); 44 | promise.resolve(getWritableMap(map)); 45 | } 46 | }; 47 | Thread thread = new Thread(runnable); 48 | thread.start(); 49 | } 50 | 51 | @ReactMethod 52 | public void setAlipaySandbox(Boolean isSandbox) { 53 | if (isSandbox) { 54 | EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX); 55 | } else { 56 | EnvUtils.setEnv(EnvUtils.EnvEnum.ONLINE); 57 | } 58 | } 59 | @ReactMethod 60 | public void alipay(final String orderInfo, final Promise promise) { 61 | Runnable payRunnable = new Runnable() { 62 | @Override 63 | public void run() { 64 | PayTask alipay = new PayTask(getCurrentActivity()); 65 | Map result = alipay.payV2(orderInfo, true); 66 | promise.resolve(getWritableMap(result)); 67 | } 68 | }; 69 | // 必须异步调用 70 | Thread payThread = new Thread(payRunnable); 71 | payThread.start(); 72 | } 73 | 74 | @ReactMethod 75 | public void getVersion(Promise promise) { 76 | PayTask payTask = new PayTask(getCurrentActivity()); 77 | promise.resolve(payTask.getVersion()); 78 | } 79 | 80 | private WritableMap getWritableMap(Map map) { 81 | WritableMap writableMap = Arguments.createMap(); 82 | for (Map.Entry entry : map.entrySet()) { 83 | writableMap.putString(entry.getKey(), entry.getValue()); 84 | } 85 | return writableMap; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /android/src/main/java/com/uiwjs/RNAlipayPackage.java: -------------------------------------------------------------------------------- 1 | package com.uiwjs.alipay; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.bridge.NativeModule; 9 | import com.facebook.react.bridge.ReactApplicationContext; 10 | import com.facebook.react.uimanager.ViewManager; 11 | import com.facebook.react.bridge.JavaScriptModule; 12 | 13 | public class RNAlipayPackage implements ReactPackage { 14 | @Override 15 | public List createNativeModules(ReactApplicationContext reactContext) { 16 | return Arrays.asList(new RNAlipayModule(reactContext)); 17 | } 18 | 19 | @Override 20 | public List createViewManagers(ReactApplicationContext reactContext) { 21 | return Collections.emptyList(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /android/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | uiwjs 3 | 4 | -------------------------------------------------------------------------------- /example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | }; 5 | -------------------------------------------------------------------------------- /example/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore polyfills 9 | node_modules/react-native/Libraries/polyfills/.* 10 | 11 | ; Flow doesn't support platforms 12 | .*/Libraries/Utilities/LoadingView.js 13 | 14 | .*/node_modules/resolve/test/resolver/malformed_package_json/package\.json$ 15 | 16 | [untyped] 17 | .*/node_modules/@react-native-community/cli/.*/.* 18 | 19 | [include] 20 | 21 | [libs] 22 | node_modules/react-native/interface.js 23 | node_modules/react-native/flow/ 24 | 25 | [options] 26 | emoji=true 27 | 28 | exact_by_default=true 29 | 30 | format.bracket_spacing=false 31 | 32 | module.file_ext=.js 33 | module.file_ext=.json 34 | module.file_ext=.ios.js 35 | 36 | munge_underscores=true 37 | 38 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 39 | module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' 40 | 41 | suppress_type=$FlowIssue 42 | suppress_type=$FlowFixMe 43 | suppress_type=$FlowFixMeProps 44 | suppress_type=$FlowFixMeState 45 | 46 | [lints] 47 | sketchy-null-number=warn 48 | sketchy-null-mixed=warn 49 | sketchy-number=warn 50 | untyped-type-import=warn 51 | nonstrict-import=warn 52 | deprecated-type=warn 53 | unsafe-getters-setters=warn 54 | unnecessary-invariant=warn 55 | 56 | [strict] 57 | deprecated-type 58 | nonstrict-import 59 | sketchy-null 60 | unclear-type 61 | unsafe-getters-setters 62 | untyped-import 63 | untyped-type-import 64 | 65 | [version] 66 | ^0.176.3 67 | -------------------------------------------------------------------------------- /example/.gitattributes: -------------------------------------------------------------------------------- 1 | # Windows files should use crlf line endings 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | *.bat text eol=crlf 4 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | ios/.xcode.env.local 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | *.hprof 33 | 34 | # node.js 35 | # 36 | node_modules/ 37 | npm-debug.log 38 | yarn-error.log 39 | 40 | # BUCK 41 | buck-out/ 42 | \.buckd/ 43 | *.keystore 44 | !debug.keystore 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/ 52 | 53 | **/fastlane/report.xml 54 | **/fastlane/Preview.html 55 | **/fastlane/screenshots 56 | **/fastlane/test_output 57 | 58 | # Bundle artifact 59 | *.jsbundle 60 | 61 | # Ruby / CocoaPods 62 | /ios/Pods/ 63 | /vendor/bundle/ 64 | -------------------------------------------------------------------------------- /example/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | arrowParens: 'avoid', 3 | bracketSameLine: true, 4 | bracketSpacing: false, 5 | singleQuote: true, 6 | trailingComma: 'all', 7 | }; 8 | -------------------------------------------------------------------------------- /example/.ruby-version: -------------------------------------------------------------------------------- 1 | 2.7.4 2 | -------------------------------------------------------------------------------- /example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /example/App.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import {StyleSheet, Button, Text, View} from 'react-native'; 3 | import Alipay from '@uiw/react-native-alipay'; 4 | 5 | export default class App extends Component { 6 | constructor(props) { 7 | super(props); 8 | this.state = { 9 | version: '', 10 | }; 11 | } 12 | componentDidMount() { 13 | Alipay.setAlipayScheme('uiwjspay'); 14 | } 15 | aliPay = async () => { 16 | try { 17 | // return_url= 18 | const payInfo = 19 | '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¬ify_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×tamp=2020-07-09+12%3A16%3A16&version=1.0'; 20 | const resule = await Alipay.alipay(payInfo); 21 | console.log('alipay:resule-->>>', resule); 22 | } catch (error) { 23 | console.log('alipay:error-->>>', error); 24 | } 25 | }; 26 | authInfo = async () => { 27 | try { 28 | const authInfoStr = 29 | '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'; 30 | const resule = await Alipay.authInfo(authInfoStr); 31 | // resule => success=true&auth_code=9c11732de44f4f1790b63978b6fbOX53&result_code=200&alipay_open_id=20881001757376426161095132517425&user_id=2088003646494707 32 | console.log('authInfo:resule-->>>', resule); 33 | } catch (error) { 34 | console.log('authInfo:error-->>>', error); 35 | } 36 | }; 37 | getVersion = async () => { 38 | try { 39 | const version = await Alipay.getVersion(); 40 | this.setState({version}); 41 | console.log('getVersion:', version); 42 | } catch (error) { 43 | console.log('getVersion:error-->>>', error); 44 | } 45 | }; 46 | render() { 47 | return ( 48 | 49 | ☆Alipay Example☆ 50 |