作者 AnstJJ

one

正在显示 66 个修改的文件 包含 1391 行增加0 行删除
  1 +
  2 +# react-native-jj-unionpay
  3 +
  4 +[![npm version](https://img.shields.io/npm/v/react-native-jy-unionpay.svg)](https://www.npmjs.com/package/react-native-jy-unionpay)
  5 +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)
  6 +
  7 +本插件参考 [银联官方 - 手机支付控件(含安卓Pay)文档](https://open.unionpay.com/tjweb/acproduct/list?apiservId=450)
  8 +## 安装
  9 +
  10 +### React Native 0.60 或以上
  11 +```sh
  12 +yarn add react-native-jy-unionpay
  13 +cd ios && pod install # for iOS
  14 +```
  15 +### React Native 0.59 以下
  16 +```sh
  17 +yarn add react-native-jy-unionpay
  18 +react-native link react-native-jy-unionpay
  19 +```
  20 +### iOS 配置
  21 +- 在工程 info.plist 设置中添加一个 URL Types 回调协议,用于在支付完成后返回商户客户端。请注意 URL Schemes 需要是唯一的。
  22 +<p align="center"><img src="https://raw.githubusercontent.com/caipeiming/react-native-jy-unionpay/master/ios_url_type.png" alt="Xcode set iOS urltypes"></p>
  23 +
  24 +- http 请求设置(ats)
  25 +
  26 +在测试环境测试时,需要在工程对应的 plist 文件中添加 NSAppTransportSecurity Dictionary 并同时设置里面NSAllowsArbitraryLoads 属性值为 YES,具体设置可参 照以下截图:
  27 +<p align="center"><img src="https://raw.githubusercontent.com/caipeiming/react-native-jy-unionpay/master/ios_ns_allows_arbitrary_loads.png" alt="Xcode set iOS NSAppTransportSecurity"></p>
  28 +向 Apple 发布正式版本时请删除此设置。
  29 +
  30 +
  31 +- 添加协议白名单
  32 +
  33 +在 Xcode7.0 之后的版本中进行开发,需要在工程对应的 plist 文件中,添加 LSApplicationQueriesSchemes Array 并加入 uppaysdk、uppaywallet、uppayx1、 uppayx2、uppayx3 五个 item,具体设置可参考以下截图:
  34 +<p align="center"><img src="https://raw.githubusercontent.com/caipeiming/react-native-jy-unionpay/master/ios_ls_application_queries_schemes.png" alt="Xcode set Info.plist LSApplicationQueriesSchemes"></p>
  35 +或者直接添加如下代码到 plist 文件中:
  36 +
  37 +```
  38 +<key>LSApplicationQueriesSchemes</key>
  39 +<array>
  40 + <string>uppaysdk</string>
  41 + <string>uppaywallet</string>
  42 + <string>uppayx1</string>
  43 + <string>uppayx2</string>
  44 + <string>uppayx3</string>
  45 +</array>
  46 +```
  47 +
  48 +- AppDelegate.m 的 下面 @end 前面添加下面代码
  49 +
  50 +```
  51 +// iOS 9.x or newer
  52 +- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
  53 +{
  54 + return [RCTLinkingManager application:application openURL:url options:options];
  55 +}
  56 +
  57 +// iOS 8.x or older
  58 +- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
  59 +{
  60 + return [RCTLinkingManager application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
  61 +}
  62 +```
  63 +
  64 +## 使用
  65 +```javascript
  66 +import {Unionpay, UnionpayEmitter, UNIONPAY_MODAL_PRODUCTION, UNIONPAY_MODAL_DEVELOPMENT} from 'react-native-china-unionpay';
  67 +```
  68 +## Api
  69 +
  70 +| Method | Return Type | iOS | Android |
  71 +| ----------------------------------------------------------------- | ------------------- | :--: | :-----: |
  72 +| [startPay(tn: string, mode: string)](#startpaytn-string-mode-string) | `void` | ✅ | ✅ |
  73 +| [startSEPay(tn: string, mode: string, seType: string)](#startsepaytn-string-mode-string-setype-string) | `void` | ❌ | ✅ |
  74 +| [getSEPayInfo()](#getsepayinfo) | `Promise<object>` | ❌ | ✅ |
  75 +| [checkWalletInstalled()](#checkwalletinstalled) | `Promise<boolean>` | ❌ | ✅ |
  76 +| [isPaymentAppInstalled()](#ispaymentappinstalled) | `Promise<boolean>` | ✅ | ❌ |
  77 +---
  78 +### startPay(tn: string, mode: string)
  79 +tn - 交易流水号
  80 +
  81 +mode - 连接环境:"00" - 银联正式环境 "01" - 银联测试环境,该环境中不发生真实交易
  82 +
  83 +通过银联工具类启动支付插件,支付结果在 [`UnionpayEmitter`](#UnionpayEmitter) 事件中获取。
  84 +#### Examples
  85 +```js
  86 +Unionpay.startPay(tn, UNIONPAY_MODAL_DEVELOPMENT);
  87 +```
  88 +### startSEPay(tn: string, mode: string, seType: string)
  89 +tn - 交易流水号
  90 +
  91 +mode - 连接环境:"00" - 银联正式环境 "01" - 银联测试环境,该环境中不发生真实交易
  92 +
  93 +seType - 手机pay支付类别
  94 +
  95 +调用指定手机Pay支付接口(startSEPay())之前,需要先调用检查手机Pay状态接口(getSEPayInfo())获取seType,startSEPay()调用方式同startPay()。
  96 +#### Examples
  97 +```js
  98 +Unionpay.startSEPay(tn, UNIONPAY_MODAL_DEVELOPMENT, seType);
  99 +```
  100 +### getSEPayInfo()
  101 +检查手机 Pay 状态接口
  102 +#### Examples
  103 +```js
  104 +Unionpay.getSEPayInfo().then(data => {
  105 + console.log(data);
  106 +}).catch(error => {
  107 + console.log(error.message);
  108 +});
  109 +```
  110 +### checkWalletInstalled()
  111 +检测是否已安装云闪付客户端接口调用
  112 +#### Examples
  113 +```js
  114 +Unionpay.checkWalletInstalled().then(data => {
  115 + console.log(data);
  116 +}).catch(error => {
  117 + console.log(error.message);
  118 +});
  119 +```
  120 +### isPaymentAppInstalled()
  121 +检测是否已安装银联 App 接口调用
  122 +#### Examples
  123 +```js
  124 +Unionpay.isPaymentAppInstalled().then(data => {
  125 + console.log(data);
  126 +});
  127 +```
  128 +### UnionpayEmitter
  129 +用于支付结果的事件订阅。支付结果的 `pay_result` 参数有3个选项:
  130 +- success 支付成功
  131 +- fail 支付失败
  132 +- cancel 用户取消了支付
  133 +#### Examples
  134 +```js
  135 +export default class App extends Component {
  136 + constructor(props) {
  137 + super(props);
  138 + this.onUnionPayResponse = this._onUnionPayResponse.bind(this);
  139 + }
  140 +
  141 + componentDidMount() {
  142 + UnionpayEmitter.on("UnionPayResponse", this.onUnionPayResponse);
  143 + }
  144 +
  145 + componentWillUnmount() {
  146 + this.isMount = false;
  147 + UnionpayEmitter.removeListener('UnionPayResponse', this.onUnionPayResponse);
  148 + }
  149 +
  150 + _onUnionPayResponse(data) {
  151 + console.log(data);
  152 + }
  153 +}
  154 +```
  155 +### mode 常量
  156 +连接环境,有2个常量选项
  157 +- UNIONPAY_MODAL_PRODUCTION
  158 +银联正式环境
  159 +- UNIONPAY_MODAL_DEVELOPMENT
  160 +银联测试环境,该环境中不发生真实交易
  161 +
  162 +
  163 +## 测试账号
  164 +
  165 +参考官网 [测试环境的测试卡信息](https://open.unionpay.com/tjweb/support/faq/mchlist?id=4)
  166 +测试卡信息-前台类交易
  167 +```
  168 +招商银行借记卡:6226090000000048
  169 + 手机号:18100000000
  170 + 密码:111101
  171 + 短信验证码:111111(先点获取验证码之后再输入)
  172 + 证件类型:01
  173 + 证件号:510265790128303
  174 + 姓名:张三
  175 +```
  176 +```
  177 +华夏银行贷记卡:6226388000000095
  178 + 手机号:18100000000
  179 + cvn2:248
  180 + 有效期:1225(后台接口注意格式YYMM需倒一下)
  181 + 短信验证码:111111(先点获取验证码之后再输入)
  182 + 证件类型:01
  183 + 证件号:510265790128303
  184 + 姓名:张三
  185 +```
  186 +```
  187 +平安银行借记卡:6216261000000000018
  188 + 手机号:13552535506
  189 + 证件类型:01
  190 + 证件号:341126197709218366
  191 + 密码:123456
  192 + 姓名:全渠道
  193 + 短信验证码:111111(先点获取验证码之后再输入)
  194 +```
  195 +```
  196 +平安银行贷记卡:6221558812340000
  197 + 手机号:13552535506
  198 + cvn2:123
  199 + 有效期:1123(后台接口注意格式YYMM需倒一下)
  200 + 短信验证码:111111(先点获取验证码之后再输入)
  201 + 姓名:互联网
  202 + 证件类型:01
  203 + 证件号:341126197709218366
  204 +```
  205 +```
  206 +农行贷记卡:5200831111111113
  207 + 手机号:13552535506
  208 + cvn2:123
  209 + 有效期:1125(后台接口注意格式YYMM需倒一下)
  210 + 短信验证码:111111(先点获取验证码之后再输入)
  211 + 姓名:全渠道
  212 + 证件类型:01
  213 + 身份证号:341126197709218366
  214 +```
  215 +```
  216 +平安银行贷记卡:6221558812340013(信用卡还款被还款信用卡)
  217 + 手机号:13552535506
  218 + cvn2:123
  219 + 有效期:1123(后台接口注意格式YYMM需倒一下)
  220 + 短信验证码:111111(先点获取验证码之后再输入)
  221 + 姓名:全渠道
  222 + 证件类型:01
  223 + 证件号:341126197709218366
  224 +```
  225 +
  226 +# 示例
  227 +- 参考 [example](https://github.com/caipeiming/react-native-china-unionpay/tree/master/example)
  228 +- 安卓手机也可以直接安装已编译的 [apk](https://github.com/caipeiming/react-native-china-unionpay/releases)
  1 +buildscript {
  2 + repositories {
  3 + jcenter()
  4 + }
  5 +
  6 + dependencies {
  7 + classpath 'com.android.tools.build:gradle:1.3.1'
  8 + }
  9 +}
  10 +
  11 +apply plugin: 'com.android.library'
  12 +
  13 +android {
  14 + compileSdkVersion 28
  15 + buildToolsVersion "23.0.1"
  16 +
  17 + defaultConfig {
  18 + minSdkVersion 16
  19 + targetSdkVersion 28
  20 + versionCode 1
  21 + versionName "1.0"
  22 + }
  23 + lintOptions {
  24 + abortOnError false
  25 + }
  26 + sourceSets.main {
  27 + jni.srcDirs = []
  28 + // 让 android studio 识别libs下的 .so 第三方包
  29 + jniLibs.srcDirs = ['libs']
  30 + }
  31 +}
  32 +
  33 +repositories {
  34 + mavenCentral()
  35 +}
  36 +
  37 +dependencies {
  38 + implementation 'com.facebook.react:react-native:+'
  39 + implementation fileTree(dir: 'libs', include: ['*.jar'])
  40 +}
  1 +#Sun Apr 12 11:37:40 CST 2020
  2 +distributionBase=GRADLE_USER_HOME
  3 +distributionPath=wrapper/dists
  4 +zipStoreBase=GRADLE_USER_HOME
  5 +zipStorePath=wrapper/dists
  6 +distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
  1 +#!/usr/bin/env sh
  2 +
  3 +##############################################################################
  4 +##
  5 +## Gradle start up script for UN*X
  6 +##
  7 +##############################################################################
  8 +
  9 +# Attempt to set APP_HOME
  10 +# Resolve links: $0 may be a link
  11 +PRG="$0"
  12 +# Need this for relative symlinks.
  13 +while [ -h "$PRG" ] ; do
  14 + ls=`ls -ld "$PRG"`
  15 + link=`expr "$ls" : '.*-> \(.*\)$'`
  16 + if expr "$link" : '/.*' > /dev/null; then
  17 + PRG="$link"
  18 + else
  19 + PRG=`dirname "$PRG"`"/$link"
  20 + fi
  21 +done
  22 +SAVED="`pwd`"
  23 +cd "`dirname \"$PRG\"`/" >/dev/null
  24 +APP_HOME="`pwd -P`"
  25 +cd "$SAVED" >/dev/null
  26 +
  27 +APP_NAME="Gradle"
  28 +APP_BASE_NAME=`basename "$0"`
  29 +
  30 +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
  31 +DEFAULT_JVM_OPTS=""
  32 +
  33 +# Use the maximum available, or set MAX_FD != -1 to use that value.
  34 +MAX_FD="maximum"
  35 +
  36 +warn () {
  37 + echo "$*"
  38 +}
  39 +
  40 +die () {
  41 + echo
  42 + echo "$*"
  43 + echo
  44 + exit 1
  45 +}
  46 +
  47 +# OS specific support (must be 'true' or 'false').
  48 +cygwin=false
  49 +msys=false
  50 +darwin=false
  51 +nonstop=false
  52 +case "`uname`" in
  53 + CYGWIN* )
  54 + cygwin=true
  55 + ;;
  56 + Darwin* )
  57 + darwin=true
  58 + ;;
  59 + MINGW* )
  60 + msys=true
  61 + ;;
  62 + NONSTOP* )
  63 + nonstop=true
  64 + ;;
  65 +esac
  66 +
  67 +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
  68 +
  69 +# Determine the Java command to use to start the JVM.
  70 +if [ -n "$JAVA_HOME" ] ; then
  71 + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
  72 + # IBM's JDK on AIX uses strange locations for the executables
  73 + JAVACMD="$JAVA_HOME/jre/sh/java"
  74 + else
  75 + JAVACMD="$JAVA_HOME/bin/java"
  76 + fi
  77 + if [ ! -x "$JAVACMD" ] ; then
  78 + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
  79 +
  80 +Please set the JAVA_HOME variable in your environment to match the
  81 +location of your Java installation."
  82 + fi
  83 +else
  84 + JAVACMD="java"
  85 + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
  86 +
  87 +Please set the JAVA_HOME variable in your environment to match the
  88 +location of your Java installation."
  89 +fi
  90 +
  91 +# Increase the maximum file descriptors if we can.
  92 +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
  93 + MAX_FD_LIMIT=`ulimit -H -n`
  94 + if [ $? -eq 0 ] ; then
  95 + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
  96 + MAX_FD="$MAX_FD_LIMIT"
  97 + fi
  98 + ulimit -n $MAX_FD
  99 + if [ $? -ne 0 ] ; then
  100 + warn "Could not set maximum file descriptor limit: $MAX_FD"
  101 + fi
  102 + else
  103 + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
  104 + fi
  105 +fi
  106 +
  107 +# For Darwin, add options to specify how the application appears in the dock
  108 +if $darwin; then
  109 + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
  110 +fi
  111 +
  112 +# For Cygwin, switch paths to Windows format before running java
  113 +if $cygwin ; then
  114 + APP_HOME=`cygpath --path --mixed "$APP_HOME"`
  115 + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
  116 + JAVACMD=`cygpath --unix "$JAVACMD"`
  117 +
  118 + # We build the pattern for arguments to be converted via cygpath
  119 + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
  120 + SEP=""
  121 + for dir in $ROOTDIRSRAW ; do
  122 + ROOTDIRS="$ROOTDIRS$SEP$dir"
  123 + SEP="|"
  124 + done
  125 + OURCYGPATTERN="(^($ROOTDIRS))"
  126 + # Add a user-defined pattern to the cygpath arguments
  127 + if [ "$GRADLE_CYGPATTERN" != "" ] ; then
  128 + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
  129 + fi
  130 + # Now convert the arguments - kludge to limit ourselves to /bin/sh
  131 + i=0
  132 + for arg in "$@" ; do
  133 + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
  134 + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
  135 +
  136 + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
  137 + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
  138 + else
  139 + eval `echo args$i`="\"$arg\""
  140 + fi
  141 + i=$((i+1))
  142 + done
  143 + case $i in
  144 + (0) set -- ;;
  145 + (1) set -- "$args0" ;;
  146 + (2) set -- "$args0" "$args1" ;;
  147 + (3) set -- "$args0" "$args1" "$args2" ;;
  148 + (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
  149 + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
  150 + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
  151 + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
  152 + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
  153 + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
  154 + esac
  155 +fi
  156 +
  157 +# Escape application args
  158 +save () {
  159 + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
  160 + echo " "
  161 +}
  162 +APP_ARGS=$(save "$@")
  163 +
  164 +# Collect all arguments for the java command, following the shell quoting and substitution rules
  165 +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
  166 +
  167 +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
  168 +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
  169 + cd "$(dirname "$0")"
  170 +fi
  171 +
  172 +exec "$JAVACMD" "$@"
  1 +@if "%DEBUG%" == "" @echo off
  2 +@rem ##########################################################################
  3 +@rem
  4 +@rem Gradle startup script for Windows
  5 +@rem
  6 +@rem ##########################################################################
  7 +
  8 +@rem Set local scope for the variables with windows NT shell
  9 +if "%OS%"=="Windows_NT" setlocal
  10 +
  11 +set DIRNAME=%~dp0
  12 +if "%DIRNAME%" == "" set DIRNAME=.
  13 +set APP_BASE_NAME=%~n0
  14 +set APP_HOME=%DIRNAME%
  15 +
  16 +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
  17 +set DEFAULT_JVM_OPTS=
  18 +
  19 +@rem Find java.exe
  20 +if defined JAVA_HOME goto findJavaFromJavaHome
  21 +
  22 +set JAVA_EXE=java.exe
  23 +%JAVA_EXE% -version >NUL 2>&1
  24 +if "%ERRORLEVEL%" == "0" goto init
  25 +
  26 +echo.
  27 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
  28 +echo.
  29 +echo Please set the JAVA_HOME variable in your environment to match the
  30 +echo location of your Java installation.
  31 +
  32 +goto fail
  33 +
  34 +:findJavaFromJavaHome
  35 +set JAVA_HOME=%JAVA_HOME:"=%
  36 +set JAVA_EXE=%JAVA_HOME%/bin/java.exe
  37 +
  38 +if exist "%JAVA_EXE%" goto init
  39 +
  40 +echo.
  41 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
  42 +echo.
  43 +echo Please set the JAVA_HOME variable in your environment to match the
  44 +echo location of your Java installation.
  45 +
  46 +goto fail
  47 +
  48 +:init
  49 +@rem Get command-line arguments, handling Windows variants
  50 +
  51 +if not "%OS%" == "Windows_NT" goto win9xME_args
  52 +
  53 +:win9xME_args
  54 +@rem Slurp the command line arguments.
  55 +set CMD_LINE_ARGS=
  56 +set _SKIP=2
  57 +
  58 +:win9xME_args_slurp
  59 +if "x%~1" == "x" goto execute
  60 +
  61 +set CMD_LINE_ARGS=%*
  62 +
  63 +:execute
  64 +@rem Setup the command line
  65 +
  66 +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
  67 +
  68 +@rem Execute Gradle
  69 +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
  70 +
  71 +:end
  72 +@rem End local scope for the variables with windows NT shell
  73 +if "%ERRORLEVEL%"=="0" goto mainEnd
  74 +
  75 +:fail
  76 +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
  77 +rem the _cmd.exe /c_ return code!
  78 +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
  79 +exit /b 1
  80 +
  81 +:mainEnd
  82 +if "%OS%"=="Windows_NT" endlocal
  83 +
  84 +:omega
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
  1 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  2 + package="com.jy.rn.unionpay">
  3 +
  4 + <uses-permission android:name="android.permission.INTERNET" />
  5 + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  6 + <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
  7 + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  8 + <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  9 + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  10 + <uses-permission android:name="android.permission.NFC" />
  11 +
  12 + <uses-feature android:name="android.hardware.nfc.hce" />
  13 + <uses-permission android:name="org.simalliance.openmobileapi.SMARTCARD" />
  14 +
  15 + <application>
  16 +
  17 + <uses-library
  18 + android:name="org.simalliance.openmobileapi"
  19 + android:required="false" />
  20 +
  21 + <activity
  22 + android:name="com.unionpay.uppay.PayActivity"
  23 + android:configChanges="orientation|keyboardHidden"
  24 + android:excludeFromRecents="true"
  25 + android:label="@string/app_name"
  26 + android:screenOrientation="portrait"
  27 + android:windowSoftInputMode="adjustResize" />
  28 +
  29 + <activity
  30 + android:name="com.unionpay.UPPayWapActivity"
  31 + android:configChanges="orientation|keyboardHidden|fontScale"
  32 + android:screenOrientation="portrait"
  33 + android:windowSoftInputMode="adjustResize"></activity>
  34 + </application>
  35 +</manifest>
  36 +
不能预览此文件类型
  1 +
  2 +package com.jy.rn.unionpay;
  3 +
  4 +import android.app.Activity;
  5 +import android.content.Intent;
  6 +import android.os.Bundle;
  7 +
  8 +import com.facebook.react.bridge.ActivityEventListener;
  9 +import com.facebook.react.bridge.Arguments;
  10 +import com.facebook.react.bridge.Promise;
  11 +import com.facebook.react.bridge.ReactApplicationContext;
  12 +import com.facebook.react.bridge.ReactContextBaseJavaModule;
  13 +import com.facebook.react.bridge.ReactMethod;
  14 +import com.facebook.react.bridge.WritableMap;
  15 +import com.facebook.react.modules.core.DeviceEventManagerModule;
  16 +import com.unionpay.UPPayAssistEx;
  17 +import com.unionpay.UPQuerySEPayInfoCallback;
  18 +import com.unionpay.UPSEInfoResp;
  19 +
  20 +import org.json.JSONException;
  21 +import org.json.JSONObject;
  22 +
  23 +import javax.annotation.Nonnull;
  24 +
  25 +public class RCTUnionpayModule extends ReactContextBaseJavaModule implements ActivityEventListener {
  26 + private final String TAG = "RCTUnionpayModule";
  27 + private ReactApplicationContext reactContext;
  28 +
  29 + public RCTUnionpayModule(@Nonnull ReactApplicationContext reactContext) {
  30 + super(reactContext);
  31 + this.reactContext = reactContext;
  32 + this.reactContext.addActivityEventListener(this);
  33 + }
  34 +
  35 + @Nonnull
  36 + @Override
  37 + public String getName() {
  38 + return "UnionPayModule";
  39 + }
  40 +
  41 + @Override
  42 + public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
  43 + // 处理银联手机支付控件返回的支付结果
  44 + if (data == null) {
  45 + return;
  46 + }
  47 + WritableMap response = Arguments.createMap();
  48 + String msg = "";
  49 + /*
  50 + * 支付控件返回字符串:success、fail、cancel 分别代表支付成功,支付失败,支付取消
  51 + */
  52 + String str = data.getExtras().getString("pay_result");
  53 + if (str.equalsIgnoreCase("success")) {
  54 + // 如果想对结果数据验签,可使用下面这段代码,但建议不验签,直接去商户后台查询交易结果
  55 + // result_data结构见c)result_data参数说明
  56 + if (data.hasExtra("result_data")) {
  57 + String result = data.getExtras().getString("result_data");
  58 + try {
  59 + JSONObject resultJson = new JSONObject(result);
  60 + String sign = resultJson.getString("sign");
  61 + String dataOrg = resultJson.getString("data");
  62 + response.putString("sign", sign);
  63 + response.putString("data", dataOrg);
  64 + /*
  65 + // 此处的verify建议送去商户后台做验签
  66 + // 如要放在手机端验,则代码必须支持更新证书
  67 + boolean ret = verify(dataOrg, sign, mMode);
  68 + if (ret) {
  69 + // 验签成功,显示支付结果
  70 + msg = "支付成功!";
  71 + } else {
  72 + // 验签失败
  73 + msg = "支付失败!";
  74 + }
  75 + */
  76 + } catch (JSONException e) {
  77 + }
  78 + }
  79 + // 结果result_data为成功时,去商户后台查询一下再展示成功
  80 + msg = "支付成功!";
  81 + } else if (str.equalsIgnoreCase("fail")) {
  82 + msg = "支付失败!";
  83 + } else if (str.equalsIgnoreCase("cancel")) {
  84 + msg = "用户取消了支付";
  85 + }
  86 + response.putString("pay_result", str);
  87 + response.putString("msg", msg);
  88 + reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("UnionPayResponse", response);
  89 + }
  90 +
  91 + @Override
  92 + public void onNewIntent(Intent intent) {
  93 +
  94 + }
  95 +
  96 + /**
  97 + * 通过银联工具类启动支付插件
  98 + *
  99 + * @param tn 交易流水号
  100 + * @param mode 连接环境:"00" - 银联正式环境 "01" - 银联测试环境,该环境中不发生真实交易
  101 + */
  102 + @ReactMethod
  103 + public void startPay(String tn, String mode) {
  104 + UPPayAssistEx.startPay(getCurrentActivity(), null, null, tn, mode);
  105 + }
  106 +
  107 + /**
  108 + * 指定手机 pay 支付接口
  109 + *
  110 + * @param tn 交易流水号
  111 + * @param mode 连接环境:"00" - 银联正式环境 "01" - 银联测试环境,该环境中不发生真实交易
  112 + * @param seType 手机pay支付类别
  113 + */
  114 + @ReactMethod
  115 + public void startSEPay(String tn, String mode, String seType) {
  116 + UPPayAssistEx.startSEPay(getCurrentActivity(), null, null, tn, mode, seType);
  117 + }
  118 +
  119 + /**
  120 + * 检查手机 pay 状态的接口
  121 + *
  122 + * @param promise
  123 + */
  124 + @ReactMethod
  125 + public void getSEPayInfo(final Promise promise) {
  126 + UPPayAssistEx.getSEPayInfo(this.reactContext, new UPQuerySEPayInfoCallback() {
  127 + @Override
  128 + public void onResult(String SEName, String seType, int cardNumbers, Bundle reserved) {
  129 + WritableMap response = Arguments.createMap();
  130 + response.putString("SEName", SEName);
  131 + response.putString("seType", seType);
  132 + response.putInt("cardNumbers", cardNumbers);
  133 + response.putMap("reserved", Arguments.fromBundle(reserved));
  134 + promise.resolve(response);
  135 + }
  136 +
  137 + @Override
  138 + public void onError(String SEName, String seType, String errorCode, String errorDesc) {
  139 + if (errorDesc == null) {
  140 + if (errorCode.equals(UPSEInfoResp.ERROR_NOT_SUPPORT)) {
  141 + errorDesc = "硬件不支持 XXpay";
  142 + } else if (errorCode.equals(UPSEInfoResp.ERROR_NOT_READY)) {
  143 + errorDesc = "未开通 XXpay";
  144 + } else if (errorCode.equals(UPSEInfoResp.ERROR_NONE)) {
  145 + errorDesc = "可用卡数为0";
  146 + } else if (errorCode.equals(UPSEInfoResp.ERROR_TSM_UNINSTALLED)) {
  147 + errorDesc = "检测未安装 TSM 控件";
  148 + } else if (errorCode.equals(UPSEInfoResp.ERROR_TIMEOUT)) {
  149 + errorDesc = "接口超时";
  150 + }
  151 + }
  152 + WritableMap response = Arguments.createMap();
  153 + response.putString("SEName", SEName);
  154 + response.putString("seType", seType);
  155 + response.putString("errorCode", errorCode);
  156 + response.putString("errorDesc", errorDesc);
  157 + promise.reject(errorCode, errorDesc, response);
  158 + }
  159 + });
  160 + }
  161 +
  162 + /**
  163 + * 检查是否安装云闪付客户端的接口
  164 + *
  165 + * @param promise
  166 + */
  167 + @ReactMethod
  168 + public void checkWalletInstalled(Promise promise) {
  169 + boolean res = UPPayAssistEx.checkWalletInstalled(getCurrentActivity());
  170 + promise.resolve(res);
  171 + }
  172 +
  173 +}
  1 +package com.jy.rn.unionpay;
  2 +
  3 +import com.facebook.react.ReactPackage;
  4 +import com.facebook.react.bridge.NativeModule;
  5 +import com.facebook.react.bridge.ReactApplicationContext;
  6 +import com.facebook.react.uimanager.ViewManager;
  7 +
  8 +import java.util.Arrays;
  9 +import java.util.Collections;
  10 +import java.util.List;
  11 +
  12 +public class RCTUnionpayPackage implements ReactPackage {
  13 + @Override
  14 + public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
  15 + return Arrays.<NativeModule>asList(new RCTUnionpayModule(reactContext));
  16 + }
  17 +
  18 + @Override
  19 + public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
  20 + return Collections.emptyList();
  21 + }
  22 +}
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<resources>
  3 + <string name="app_name">Unionpay</string>
  4 +</resources>
  1 +
  2 +#import <React/RCTBridgeModule.h>
  3 +#import "RCTEventEmitter.h"
  4 +
  5 +@interface RNUnionpay : RCTEventEmitter <RCTBridgeModule>
  6 +
  7 +@property NSString* schemeStr;
  8 +
  9 +@end
  10 +
  1 +
  2 +#import "RNUnionpay.h"
  3 +#import "UPPaymentControl.h"
  4 +
  5 +@implementation RNUnionpay
  6 +
  7 +- (instancetype)init
  8 +{
  9 + self = [super init];
  10 + if (self) {
  11 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:@"RCTOpenURLNotification" object:nil];
  12 + }
  13 + self.schemeStr = nil;
  14 + NSArray *urlTypes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"];
  15 + if (urlTypes != nil && urlTypes.count > 0) {
  16 + NSArray *urlSchemes = [urlTypes.firstObject objectForKey:@"CFBundleURLSchemes"];
  17 + if(urlSchemes.count > 0) {
  18 + self.schemeStr = [urlSchemes firstObject];
  19 + }
  20 + }
  21 + return self;
  22 +}
  23 +
  24 ++ (BOOL)requiresMainQueueSetup{
  25 + return YES;
  26 +}
  27 +
  28 +- (NSArray<NSString *> *)supportedEvents
  29 +{
  30 + return @[@"UnionPayResponse"];
  31 +}
  32 +
  33 +- (BOOL)handleOpenURL:(NSNotification *)aNotification
  34 +{
  35 + NSString * aURLString = [aNotification userInfo][@"url"];
  36 + NSURL * aURL = [NSURL URLWithString:aURLString];
  37 + [[UPPaymentControl defaultControl] handlePaymentResult:aURL completeBlock:^(NSString *code, NSDictionary *data) {
  38 + NSString *sign;
  39 + NSMutableDictionary *body = [[NSMutableDictionary alloc]init];
  40 + [body setValue:code forKey:@"pay_result"];
  41 + //结果code为成功时,去商户后台查询一下确保交易是成功的再展示成功
  42 + if([code isEqualToString:@"success"]) {
  43 + [body setValue:@"支付成功!" forKey:@"msg"];
  44 + //判断签名数据是否存在
  45 + //如果没有签名数据,建议商户app后台查询交易结果
  46 + if(data == nil){
  47 + [body setValue:nil forKey:@"sign"];
  48 + } else {
  49 + //数据从NSDictionary转换为NSString
  50 + NSData *signData = [NSJSONSerialization dataWithJSONObject:data
  51 + options:0
  52 + error:nil];
  53 + sign = [[NSString alloc] initWithData:signData encoding:NSUTF8StringEncoding];
  54 + [body setValue:sign forKey:@"sign"];
  55 + }
  56 + }
  57 + else if([code isEqualToString:@"fail"]) { //交易失败
  58 + [body setValue:@"支付失败!" forKey:@"msg"];
  59 + }
  60 + else if([code isEqualToString:@"cancel"]) { //交易取消
  61 + [body setValue:@"用户取消了支付" forKey:@"msg"];
  62 + }
  63 + [self sendEventWithName:@"UnionPayResponse" body:body];
  64 + }];
  65 + return YES;
  66 +}
  67 +
  68 +
  69 +RCT_EXPORT_MODULE(UnionPayModule)
  70 +
  71 +RCT_EXPORT_METHOD(startPay:(NSString*)tn :(NSString*)mode)
  72 +{
  73 + //当获得的tn不为空时,调用支付接口
  74 + if (tn != nil && tn.length > 0){
  75 + dispatch_async(dispatch_get_main_queue(), ^(void) {
  76 + UIWindow *window = [UIApplication sharedApplication].keyWindow;
  77 + UIViewController *rootViewController = window.rootViewController;
  78 + [[UPPaymentControl defaultControl] startPay:tn
  79 + fromScheme:self.schemeStr mode:mode
  80 + viewController:rootViewController];
  81 + });
  82 + }
  83 +}
  84 +
  85 +
  86 +/// 当判断用户手机上已安装银联App,商户客户端可以做相应个性化处理
  87 +/// @param resolve
  88 +/// @param reject
  89 +RCT_EXPORT_METHOD(isPaymentAppInstalled:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject)
  90 +{
  91 + if([[UPPaymentControl defaultControl] isPaymentAppInstalled]) {
  92 + resolve(@(YES));
  93 + } else {
  94 + resolve(@(NO));
  95 + }
  96 +}
  97 +
  98 +@end
  99 +
  1 +require "json"
  2 +package = JSON.parse(File.read('../package.json'))
  3 +
  4 +Pod::Spec.new do |s|
  5 + s.name = "RNUnionpay"
  6 + s.version = package['version']
  7 + s.summary = package["description"]
  8 + s.license = "MIT"
  9 + s.author = "qijingyu2013"
  10 + s.platform = :ios, "8.0"
  11 + s.homepage = "https://github.com/qijingyu2013/react-native-jy-unionpay"
  12 + s.source = { :git => "https://github.com/qijingyu2013/react-native-jy-unionpay", :tag => "1.1.0" }
  13 + s.source_files = "RNUnionpay/**/*.{h,m}"
  14 + s.requires_arc = true
  15 + s.frameworks = 'CFNetwork','SystemConfiguration'
  16 + s.libraries = 'z'
  17 + s.vendored_libraries = "RNUnionpay/paymentcontrol/*.a"
  18 +
  19 + s.dependency "React"
  20 +
  21 +end
  22 +
  1 +// !$*UTF8*$!
  2 +{
  3 + archiveVersion = 1;
  4 + classes = {
  5 + };
  6 + objectVersion = 46;
  7 + objects = {
  8 +
  9 +/* Begin PBXBuildFile section */
  10 + B3E7B58A1CC2AC0600A0062D /* RNUnionpay.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNUnionpay.m */; };
  11 +/* End PBXBuildFile section */
  12 +
  13 +/* Begin PBXCopyFilesBuildPhase section */
  14 + 58B511D91A9E6C8500147676 /* CopyFiles */ = {
  15 + isa = PBXCopyFilesBuildPhase;
  16 + buildActionMask = 2147483647;
  17 + dstPath = "include/$(PRODUCT_NAME)";
  18 + dstSubfolderSpec = 16;
  19 + files = (
  20 + );
  21 + runOnlyForDeploymentPostprocessing = 0;
  22 + };
  23 +/* End PBXCopyFilesBuildPhase section */
  24 +
  25 +/* Begin PBXFileReference section */
  26 + 134814201AA4EA6300B7C361 /* libRNUnionpay.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNUnionpay.a; sourceTree = BUILT_PRODUCTS_DIR; };
  27 + A31BAFC2242C5E4B00674CE4 /* UPPaymentControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UPPaymentControl.h; sourceTree = "<group>"; };
  28 + A31BAFC3242C5E4B00674CE4 /* libPaymentControl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libPaymentControl.a; sourceTree = "<group>"; };
  29 + B3E7B5881CC2AC0600A0062D /* RNUnionpay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNUnionpay.h; sourceTree = "<group>"; };
  30 + B3E7B5891CC2AC0600A0062D /* RNUnionpay.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNUnionpay.m; sourceTree = "<group>"; };
  31 +/* End PBXFileReference section */
  32 +
  33 +/* Begin PBXFrameworksBuildPhase section */
  34 + 58B511D81A9E6C8500147676 /* Frameworks */ = {
  35 + isa = PBXFrameworksBuildPhase;
  36 + buildActionMask = 2147483647;
  37 + files = (
  38 + );
  39 + runOnlyForDeploymentPostprocessing = 0;
  40 + };
  41 +/* End PBXFrameworksBuildPhase section */
  42 +
  43 +/* Begin PBXGroup section */
  44 + 134814211AA4EA7D00B7C361 /* Products */ = {
  45 + isa = PBXGroup;
  46 + children = (
  47 + 134814201AA4EA6300B7C361 /* libRNUnionpay.a */,
  48 + );
  49 + name = Products;
  50 + sourceTree = "<group>";
  51 + };
  52 + 58B511D21A9E6C8500147676 = {
  53 + isa = PBXGroup;
  54 + children = (
  55 + A31BAFC1242C5E4B00674CE4 /* paymentcontrol */,
  56 + B3E7B5881CC2AC0600A0062D /* RNUnionpay.h */,
  57 + B3E7B5891CC2AC0600A0062D /* RNUnionpay.m */,
  58 + 134814211AA4EA7D00B7C361 /* Products */,
  59 + );
  60 + sourceTree = "<group>";
  61 + };
  62 + A31BAFC1242C5E4B00674CE4 /* paymentcontrol */ = {
  63 + isa = PBXGroup;
  64 + children = (
  65 + A31BAFC2242C5E4B00674CE4 /* UPPaymentControl.h */,
  66 + A31BAFC3242C5E4B00674CE4 /* libPaymentControl.a */,
  67 + );
  68 + path = paymentcontrol;
  69 + sourceTree = "<group>";
  70 + };
  71 +/* End PBXGroup section */
  72 +
  73 +/* Begin PBXNativeTarget section */
  74 + 58B511DA1A9E6C8500147676 /* RNUnionpay */ = {
  75 + isa = PBXNativeTarget;
  76 + buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNUnionpay" */;
  77 + buildPhases = (
  78 + 58B511D71A9E6C8500147676 /* Sources */,
  79 + 58B511D81A9E6C8500147676 /* Frameworks */,
  80 + 58B511D91A9E6C8500147676 /* CopyFiles */,
  81 + );
  82 + buildRules = (
  83 + );
  84 + dependencies = (
  85 + );
  86 + name = RNUnionpay;
  87 + productName = RCTDataManager;
  88 + productReference = 134814201AA4EA6300B7C361 /* libRNUnionpay.a */;
  89 + productType = "com.apple.product-type.library.static";
  90 + };
  91 +/* End PBXNativeTarget section */
  92 +
  93 +/* Begin PBXProject section */
  94 + 58B511D31A9E6C8500147676 /* Project object */ = {
  95 + isa = PBXProject;
  96 + attributes = {
  97 + LastUpgradeCheck = 0830;
  98 + ORGANIZATIONNAME = Facebook;
  99 + TargetAttributes = {
  100 + 58B511DA1A9E6C8500147676 = {
  101 + CreatedOnToolsVersion = 6.1.1;
  102 + };
  103 + };
  104 + };
  105 + buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNUnionpay" */;
  106 + compatibilityVersion = "Xcode 3.2";
  107 + developmentRegion = English;
  108 + hasScannedForEncodings = 0;
  109 + knownRegions = (
  110 + English,
  111 + en,
  112 + );
  113 + mainGroup = 58B511D21A9E6C8500147676;
  114 + productRefGroup = 58B511D21A9E6C8500147676;
  115 + projectDirPath = "";
  116 + projectRoot = "";
  117 + targets = (
  118 + 58B511DA1A9E6C8500147676 /* RNUnionpay */,
  119 + );
  120 + };
  121 +/* End PBXProject section */
  122 +
  123 +/* Begin PBXSourcesBuildPhase section */
  124 + 58B511D71A9E6C8500147676 /* Sources */ = {
  125 + isa = PBXSourcesBuildPhase;
  126 + buildActionMask = 2147483647;
  127 + files = (
  128 + B3E7B58A1CC2AC0600A0062D /* RNUnionpay.m in Sources */,
  129 + );
  130 + runOnlyForDeploymentPostprocessing = 0;
  131 + };
  132 +/* End PBXSourcesBuildPhase section */
  133 +
  134 +/* Begin XCBuildConfiguration section */
  135 + 58B511ED1A9E6C8500147676 /* Debug */ = {
  136 + isa = XCBuildConfiguration;
  137 + buildSettings = {
  138 + ALWAYS_SEARCH_USER_PATHS = NO;
  139 + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
  140 + CLANG_CXX_LIBRARY = "libc++";
  141 + CLANG_ENABLE_MODULES = YES;
  142 + CLANG_ENABLE_OBJC_ARC = YES;
  143 + CLANG_WARN_BOOL_CONVERSION = YES;
  144 + CLANG_WARN_CONSTANT_CONVERSION = YES;
  145 + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
  146 + CLANG_WARN_EMPTY_BODY = YES;
  147 + CLANG_WARN_ENUM_CONVERSION = YES;
  148 + CLANG_WARN_INFINITE_RECURSION = YES;
  149 + CLANG_WARN_INT_CONVERSION = YES;
  150 + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
  151 + CLANG_WARN_SUSPICIOUS_MOVE = YES;
  152 + CLANG_WARN_UNREACHABLE_CODE = YES;
  153 + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
  154 + COPY_PHASE_STRIP = NO;
  155 + ENABLE_STRICT_OBJC_MSGSEND = YES;
  156 + ENABLE_TESTABILITY = YES;
  157 + GCC_C_LANGUAGE_STANDARD = gnu99;
  158 + GCC_DYNAMIC_NO_PIC = NO;
  159 + GCC_NO_COMMON_BLOCKS = YES;
  160 + GCC_OPTIMIZATION_LEVEL = 0;
  161 + GCC_PREPROCESSOR_DEFINITIONS = (
  162 + "DEBUG=1",
  163 + "$(inherited)",
  164 + );
  165 + GCC_SYMBOLS_PRIVATE_EXTERN = NO;
  166 + GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
  167 + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
  168 + GCC_WARN_UNDECLARED_SELECTOR = YES;
  169 + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
  170 + GCC_WARN_UNUSED_FUNCTION = YES;
  171 + GCC_WARN_UNUSED_VARIABLE = YES;
  172 + IPHONEOS_DEPLOYMENT_TARGET = 8.0;
  173 + MTL_ENABLE_DEBUG_INFO = YES;
  174 + ONLY_ACTIVE_ARCH = YES;
  175 + SDKROOT = iphoneos;
  176 + };
  177 + name = Debug;
  178 + };
  179 + 58B511EE1A9E6C8500147676 /* Release */ = {
  180 + isa = XCBuildConfiguration;
  181 + buildSettings = {
  182 + ALWAYS_SEARCH_USER_PATHS = NO;
  183 + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
  184 + CLANG_CXX_LIBRARY = "libc++";
  185 + CLANG_ENABLE_MODULES = YES;
  186 + CLANG_ENABLE_OBJC_ARC = YES;
  187 + CLANG_WARN_BOOL_CONVERSION = YES;
  188 + CLANG_WARN_CONSTANT_CONVERSION = YES;
  189 + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
  190 + CLANG_WARN_EMPTY_BODY = YES;
  191 + CLANG_WARN_ENUM_CONVERSION = YES;
  192 + CLANG_WARN_INFINITE_RECURSION = YES;
  193 + CLANG_WARN_INT_CONVERSION = YES;
  194 + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
  195 + CLANG_WARN_SUSPICIOUS_MOVE = YES;
  196 + CLANG_WARN_UNREACHABLE_CODE = YES;
  197 + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
  198 + COPY_PHASE_STRIP = YES;
  199 + ENABLE_NS_ASSERTIONS = NO;
  200 + ENABLE_STRICT_OBJC_MSGSEND = YES;
  201 + GCC_C_LANGUAGE_STANDARD = gnu99;
  202 + GCC_NO_COMMON_BLOCKS = YES;
  203 + GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
  204 + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
  205 + GCC_WARN_UNDECLARED_SELECTOR = YES;
  206 + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
  207 + GCC_WARN_UNUSED_FUNCTION = YES;
  208 + GCC_WARN_UNUSED_VARIABLE = YES;
  209 + IPHONEOS_DEPLOYMENT_TARGET = 8.0;
  210 + MTL_ENABLE_DEBUG_INFO = NO;
  211 + SDKROOT = iphoneos;
  212 + VALIDATE_PRODUCT = YES;
  213 + };
  214 + name = Release;
  215 + };
  216 + 58B511F01A9E6C8500147676 /* Debug */ = {
  217 + isa = XCBuildConfiguration;
  218 + buildSettings = {
  219 + HEADER_SEARCH_PATHS = (
  220 + "$(inherited)",
  221 + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
  222 + "$(SRCROOT)/../../../React/**",
  223 + "$(SRCROOT)/../../react-native/React/**",
  224 + );
  225 + LIBRARY_SEARCH_PATHS = "$(inherited)";
  226 + OTHER_LDFLAGS = "-ObjC";
  227 + PRODUCT_NAME = RNUnionpay;
  228 + SKIP_INSTALL = YES;
  229 + };
  230 + name = Debug;
  231 + };
  232 + 58B511F11A9E6C8500147676 /* Release */ = {
  233 + isa = XCBuildConfiguration;
  234 + buildSettings = {
  235 + HEADER_SEARCH_PATHS = (
  236 + "$(inherited)",
  237 + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
  238 + "$(SRCROOT)/../../../React/**",
  239 + "$(SRCROOT)/../../react-native/React/**",
  240 + );
  241 + LIBRARY_SEARCH_PATHS = "$(inherited)";
  242 + OTHER_LDFLAGS = "-ObjC";
  243 + PRODUCT_NAME = RNUnionpay;
  244 + SKIP_INSTALL = YES;
  245 + };
  246 + name = Release;
  247 + };
  248 +/* End XCBuildConfiguration section */
  249 +
  250 +/* Begin XCConfigurationList section */
  251 + 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNUnionpay" */ = {
  252 + isa = XCConfigurationList;
  253 + buildConfigurations = (
  254 + 58B511ED1A9E6C8500147676 /* Debug */,
  255 + 58B511EE1A9E6C8500147676 /* Release */,
  256 + );
  257 + defaultConfigurationIsVisible = 0;
  258 + defaultConfigurationName = Release;
  259 + };
  260 + 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNUnionpay" */ = {
  261 + isa = XCConfigurationList;
  262 + buildConfigurations = (
  263 + 58B511F01A9E6C8500147676 /* Debug */,
  264 + 58B511F11A9E6C8500147676 /* Release */,
  265 + );
  266 + defaultConfigurationIsVisible = 0;
  267 + defaultConfigurationName = Release;
  268 + };
  269 +/* End XCConfigurationList section */
  270 + };
  271 + rootObject = 58B511D31A9E6C8500147676 /* Project object */;
  272 +}
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<Workspace
  3 + version = "1.0">
  4 + <FileRef
  5 + location = "self:">
  6 + </FileRef>
  7 +</Workspace>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3 +<plist version="1.0">
  4 +<dict>
  5 + <key>IDEDidComputeMac32BitWarning</key>
  6 + <true/>
  7 +</dict>
  8 +</plist>
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3 +<plist version="1.0">
  4 +<dict>
  5 + <key>SchemeUserState</key>
  6 + <dict>
  7 + <key>RNUnionpay.xcscheme_^#shared#^_</key>
  8 + <dict>
  9 + <key>orderHint</key>
  10 + <integer>0</integer>
  11 + </dict>
  12 + </dict>
  13 +</dict>
  14 +</plist>
  1 +// !$*UTF8*$!
  2 +<?xml version="1.0" encoding="UTF-8"?>
  3 +<Workspace
  4 + version = "1.0">
  5 + <FileRef
  6 + location = "group:RNUnionpay.xcodeproj">
  7 + </FileRef>
  8 +</Workspace>
  9 +
  1 +//
  2 +// PaymentControl.h
  3 +// PaymentControl
  4 +//
  5 +// Created by qcao on 15/10/20.
  6 +// Copyright © 2015年 China Unionpay Co.,Ltd. All rights reserved.
  7 +// v3.3.14 bulid1
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import <UIKit/UIKit.h>
  11 +
  12 +
  13 +typedef void (^UPPaymentResultBlock)(NSString* code, NSDictionary* data);
  14 +
  15 +
  16 +@interface UPPaymentControl : NSObject
  17 +
  18 +
  19 +/**
  20 + * 创建支付单例服务
  21 + *
  22 + * @return 返回单例对象
  23 + */
  24 +
  25 ++ (UPPaymentControl *)defaultControl;
  26 +
  27 +
  28 +/**
  29 + * 支付接口
  30 + *
  31 + * @param tn 订单信息
  32 + * @param schemeStr 调用支付的app注册在info.plist中的scheme
  33 + * @param mode 支付环境
  34 + * @param viewController 启动支付控件的viewController
  35 + * @return 返回成功失败
  36 + */
  37 +- (BOOL)startPay:(NSString*)tn
  38 + fromScheme:(NSString *)schemeStr
  39 + mode:(NSString*)mode
  40 + viewController:(UIViewController*)viewController;
  41 +
  42 +
  43 +
  44 +/**
  45 + * APP是否已安装检测接口,通过该接口得知用户是否安装银联支付的APP。
  46 + *
  47 + * @return 返回是否已经安装了银联支付APP
  48 + */
  49 +
  50 +
  51 +- (BOOL)isPaymentAppInstalled;
  52 +
  53 +/**
  54 + * 处理钱包或者独立快捷app支付跳回商户app携带的支付结果Url
  55 + *
  56 + * @param url 支付结果url,传入后由SDK解析
  57 + * @param completionBlock 结果回调,保证跳转钱包支付过程中,即使调用方app被系统kill时,能通过这个回调取到支付结果。
  58 + */
  59 +
  60 +- (void)handlePaymentResult:(NSURL*)url completeBlock:(UPPaymentResultBlock)completionBlock;
  61 +
  62 +@end
不能预览此文件类型
  1 +{
  2 + "name": "react-native-jy-unionpay",
  3 + "version": "1.0.3",
  4 + "description": "银联的react-native模块",
  5 + "main": "src/index.js",
  6 + "scripts": {
  7 + "test": "echo \"Error: no test specified\" && exit 1"
  8 + },
  9 + "keywords": [
  10 + "react",
  11 + "native",
  12 + "rn",
  13 + "wechat",
  14 + "alipay",
  15 + "pay",
  16 + "jy",
  17 + "react-native",
  18 + "react-native-jy-unionpay",
  19 + "china unionpay",
  20 + "unionpay",
  21 + "china",
  22 + "银联",
  23 + "中国银联",
  24 + "银联支付",
  25 + "中国银联支付"
  26 + ],
  27 + "author": "jingyu.qi",
  28 + "homepage": "https://github.com/qijingyu2013/react-native-jy-unionpay.git",
  29 + "license": "MIT",
  30 + "peerDependencies": {
  31 + "react-native": "^0.41.2"
  32 + },
  33 + "dependencies": {
  34 + "events": "^3.1.0"
  35 + }
  36 +}
  1 +import { NativeModules } from 'react-native';
  2 +
  3 +const { UnionPayModule } = NativeModules;
  4 +
  5 +class Api {
  6 + /**
  7 + * 通过银联工具类启动支付插件
  8 + * @param {[type]} tn: string 交易流水号
  9 + * @param {[type]} mode: string 连接环境:"00" - 银联正式环境 "01" - 银联测试环境,该环境中不发生真实交易
  10 + */
  11 + startPay(tn: string, mode: string) {
  12 + UnionPayModule.startPay(tn, mode);
  13 + }
  14 +
  15 + /**
  16 + * 指定手机 pay 支付接口
  17 + * @param {[type]} tn: string 交易流水号
  18 + * @param {[type]} mode: string 连接环境:"00" - 银联正式环境 "01" - 银联测试环境,该环境中不发生真实交易
  19 + * @param {[type]} seType: string 手机pay支付类别
  20 + */
  21 + startSEPay(tn: string, mode: string, seType: string) {
  22 + UnionPayModule.startSEPay(tn, mode, seType);
  23 + }
  24 +
  25 + /**
  26 + * 检查手机 pay 状态的接口
  27 + * @return {[type]} Promise
  28 + */
  29 + getSEPayInfo(): Promise {
  30 + return UnionPayModule.getSEPayInfo();
  31 + }
  32 +
  33 + /**
  34 + * 检查是否安装云闪付客户端的接口
  35 + * @return {[type]} Promise
  36 + */
  37 + checkWalletInstalled(): Promise {
  38 + return UnionPayModule.checkWalletInstalled();
  39 + }
  40 +}
  41 +
  42 +export const Unionpay = new Api();
  1 +import { NativeModules } from 'react-native';
  2 +
  3 +const { UnionPayModule } = NativeModules;
  4 +
  5 +class Api {
  6 + /**
  7 + * 通过银联工具类启动支付插件
  8 + * @param {[type]} tn: string 交易流水号
  9 + * @param {[type]} mode: string 连接环境:"00" - 银联正式环境 "01" - 银联测试环境,该环境中不发生真实交易
  10 + */
  11 + startPay(tn: string, mode: string) {
  12 + UnionPayModule.startPay(tn, mode);
  13 + }
  14 +
  15 + /**
  16 + * 检查是否安装银联 App 的接口
  17 + * @return {[type]} Promise
  18 + */
  19 + isPaymentAppInstalled(): Promise {
  20 + return UnionPayModule.isPaymentAppInstalled();
  21 + }
  22 +}
  23 +
  24 +export const Unionpay = new Api();
  1 +export * from './api';
  2 +export * from './unionpay-event';
  3 +export * from './unionpay-modal';
  1 +import { NativeModules } from 'react-native';
  2 +
  3 +export const NativeModule = NativeModules.UnionPayModule
  1 +import { NativeEventEmitter } from 'react-native'
  2 +import EventEmitter from 'events';
  3 +import { NativeModule } from './native-module'
  4 +
  5 +class MyEmitter extends EventEmitter {}
  6 +
  7 +export const UnionpayEmitter = new MyEmitter();
  8 +
  9 +const nativeEventEmitter = new NativeEventEmitter(NativeModule);
  10 +
  11 +nativeEventEmitter.addListener('UnionPayResponse', (data) => {
  12 + UnionpayEmitter.emit('UnionPayResponse', data);
  13 +});
  1 +export const UNIONPAY_MODAL_PRODUCTION = "00";
  2 +export const UNIONPAY_MODAL_DEVELOPMENT = "01";