Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ $ react-native link react-native-puti-pay

#### Android

在android/app/build.gradle下
```
repositories {
flatDir {
dirs 'libs','../../node_modules/react-native-puti-pay/android/libs'
}
}

```

在包名目录下创建wxapi文件夹,新建一个名为`WXPayEntryActivity`的activity继承 `com.puti.paylib`包名下的`XWXPayEntryActivity`。

```
Expand Down Expand Up @@ -169,4 +179,4 @@ $ react-native link react-native-puti-pay

2. ios 支付完没有返回商家按钮
ios应用间跳转判断跳转到哪个应用是通过上面ios配置第三部设置的URL Scheme区分的。`XPay.setWxId()`,`XPay.setAlipayScheme()` 方法都是通过支付的sdk将Scheme传给微信支付宝,支付成功后才能正确跳转回应用,也才有返回商家按钮
所有要是没有此功能,请再对照文档检查一遍
所有要是没有此功能,请再对照文档检查一遍
Binary file modified android/.DS_Store
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file added android/.gradle/7.0-rc-1/fileHashes/fileHashes.lock
Binary file not shown.
Empty file.
Binary file added android/.gradle/checksums/checksums.lock
Binary file not shown.
Empty file.
Empty file.
28 changes: 28 additions & 0 deletions android/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>android</name>
<comment>Project android created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
<id>1631606901641</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
13 changes: 13 additions & 0 deletions android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.0-rc-1))
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true
10 changes: 9 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ android {
versionCode 1
versionName "1.0"
}
repositories {
flatDir {
dirs 'libs'
}
}
sourceSets.main.jniLibs.srcDirs=['libs']

buildTypes {
release {
minifyEnabled false
Expand All @@ -23,8 +30,9 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.facebook.react:react-native:+'
// From node_modules
compile files('libs/alipaySdk-20180601.jar')
compile (name: 'alipaysdk-15.8.03.210428205839', ext: 'aar')
compile 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+'
}
Binary file removed android/libs/alipaySdk-20180601.jar
Binary file not shown.
Binary file added android/libs/alipaysdk-15.8.03.210428205839.aar
Binary file not shown.
12 changes: 0 additions & 12 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@
android:label="@string/app_name"
android:supportsRtl="true">

<activity
android:name="com.alipay.sdk.app.H5PayActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:exported="false"
android:screenOrientation="behind"
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name="com.alipay.sdk.app.H5AuthActivity"
android:configChanges="orientation|keyboardHidden|navigation"
android:exported="false"
android:screenOrientation="behind"
android:windowSoftInputMode="adjustResize|stateHidden" />

</application>

Expand Down
29 changes: 29 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
type wxParams = {
partnerId: string;
prepayId: string;
packageValue: string;
nonceStr: string;
timeStamp: string;
sign: string;
};
type aliRes = {
memo: string;
result: string;
resultStatus: string;
};
type wxRes = {
errStr: string;
errCode: string;
type: string;
};
export declare class XPay {
static alipay: (orderInfo: string, callback: (res: aliRes) => void) => void;

static setWxId: (id: string) => void;

static setAlipayScheme: (scheme: string) => void;

static setAlipaySandbox: (isSandBox: boolean) => void;

static wxPay: (params: wxParams, callback: (res: wxRes) => void) => void;
}
77 changes: 37 additions & 40 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,44 @@
* GitHub:https://github.com/puti94
* Email:1059592160@qq.com
*/
import {NativeModules, Platform} from 'react-native'
import { NativeModules, Platform } from "react-native";

export default class XPay {

/**
* 支付宝Android端支付
* @param orderInfo 订单号
* @param callback 支付宝回调结果 详情见 https://docs.open.alipay.com/204/105301
*/
static alipay(orderInfo, callback) {
NativeModules.PutiPay.alipay(orderInfo, callback)
}
export class XPay {
/**
* 支付宝Android端支付
* @param orderInfo 订单号
* @param callback 支付宝回调结果 详情见 https://docs.open.alipay.com/204/105301
*/
static alipay(orderInfo, callback) {
NativeModules.PutiPay.alipay(orderInfo, callback);
}

/**
* 设置微信APPID
* @param id
*/
static setWxId(id) {
NativeModules.PutiPay.setWxId(id);
}

/**
* 设置微信APPID
* @param id
*/
static setWxId(id) {
NativeModules.PutiPay.setWxId(id);
}

/**
* 设置支付宝跳转Scheme
* @param scheme
*/
static setAlipayScheme(scheme) {
if (Platform.OS === 'ios')
NativeModules.PutiPay.setAlipayScheme(scheme);
}
/**
* 设置支付宝跳转Scheme
* @param scheme
*/
static setAlipayScheme(scheme) {
if (Platform.OS === "ios") NativeModules.PutiPay.setAlipayScheme(scheme);
}

/**
* 设置支付宝沙箱环境,仅Android
* @param isSandBox
*/
static setAlipaySandbox(isSandBox) {
if (Platform.OS === 'android')
NativeModules.PutiPay.setAlipaySandbox(isSandBox);
}
/**
* 设置支付宝沙箱环境,仅Android
* @param isSandBox
*/
static setAlipaySandbox(isSandBox) {
if (Platform.OS === "android")
NativeModules.PutiPay.setAlipaySandbox(isSandBox);
}

/**
/**
* 微信支付
* 传入参数示例
* {
Expand All @@ -62,7 +59,7 @@ export default class XPay {
* -1:原因:支付错误,可能的原因:签名错误、未注册APPID、项目设置APPID不正确、注册的APPID与设置的不匹配、其他异常等
* -2: 原因 用户取消,无需处理。发生场景:用户不支付了,点击取消,返回APP
*/
static wxPay(params, callBack) {
NativeModules.PutiPay.wxPay(params, callBack)
}
}
static wxPay(params, callBack) {
NativeModules.PutiPay.wxPay(params, callBack);
}
}
2 changes: 1 addition & 1 deletion ios/AlipaySDK.bundle/bridge.js
100755 → 100644

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified ios/AlipaySDK.framework/AlipaySDK
Binary file not shown.
56 changes: 56 additions & 0 deletions ios/AlipaySDK.framework/Headers/AFServiceCenter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// AFServiceCenter.h
// AFServiceSDK
//
// Created by jiajunchen on 02/01/2018.
// Copyright © 2018 antfin. All rights reserved.
//

#import <Foundation/Foundation.h>

@class AFServiceResponse;

/**
SDK支持的业务枚举值

- AFServiceEInvoice: 电子发票
- AFServiceAuth: 账户授权
*/
typedef NS_ENUM(NSUInteger, AFService) {
AFServiceEInvoice,
AFServiceAuth,
AFServiceDeduct
};


extern NSString * const kAFServiceOptionBizParams; // 钱包服务调用入参
extern NSString * const kAFServiceOptionCallbackScheme; // 业务回跳当前app的scheme
extern NSString * const kAFServiceOptionNotUseLanding; // 不使用支付宝提示下载页做补偿,为true时需要商户自己处理用户未安装支付宝的情况
extern NSString * const kAFServiceBizParamsKeyUrl; // 独立签约入参url

typedef void(^AFServiceResultBlock)(AFServiceResponse *response);

@interface AFServiceCenter : NSObject

/**
调用钱包服务

@param service 业务service, 见AFService枚举值
@param params 参数Dictionary, key值详情参见kAFServiceOptionBizParams、kAFServiceOptionCallbackScheme注释
@param block 业务结果回调的block, block参数是AFServiceResponse类型,业务结果通过result属性获取,如果未用户未安装支付宝并且kAFServiceOptionNotUseLanding未设置为true,会使用H5landing页做补偿,这种情况下不会有block回调结果。
*/
+ (void)callService:(AFService)service
withParams:(NSDictionary *)params
andCompletion:(AFServiceResultBlock)block;


/**
处理钱包服务回跳APP的URL

@param url 回跳URL
@param block 业务结果回掉的block,详情见调用接口入参上的block。注意此接口上的block只有在跳转钱包后,当前APP被系统回收的情况下回跳才生效
*/
+ (void)handleResponseURL:(NSURL *)url
withCompletion:(AFServiceResultBlock)block;

@end
43 changes: 43 additions & 0 deletions ios/AlipaySDK.framework/Headers/AFServiceResponse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// AFServiceResponse.h
// AFServiceSDK
//
// Created by jiajunchen on 08/01/2018.
// Copyright © 2018 antfin. All rights reserved.
//

#import <Foundation/Foundation.h>

/**
钱包服务调用结果状态吗

- AFResSuccess: 默认值,业务调用成功,结果数据参见result字段
- AFResInvalidService: service枚举值错误
- AFResInvalidURL: 钱包回跳URL错误
- AFResRepeatCall: 业务重复调用(3s内)
- AFResOpenURLErr: 跳转失败
*/
typedef NS_ENUM(NSUInteger, AFResCode) {
AFResSuccess = 0,
AFResInvalidService = 100,
AFResInvalidURL,
AFResRepeatCall,
AFResOpenURLErr,
};


@interface AFServiceResponse : NSObject


/**
业务调用状态吗
*/
@property (nonatomic, assign) AFResCode responseCode;


/**
业务结果Dictionary, 内容请参考具体业务方接入文档
*/
@property (readonly) NSDictionary *result;

@end
28 changes: 24 additions & 4 deletions ios/AlipaySDK.framework/Headers/AlipaySDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

////////////////////////////////////////////////////////
///////////////// 支付宝标准版本支付SDK ///////////////////
/////////// version:15.5.9 motify:2018.11.26///////////
///////// version:15.8.03 motify:2021.04.29///////////
////////////////////////////////////////////////////////

#import <UIKit/UIKit.h>
#import "APayAuthInfo.h"
#import "AFServiceCenter.h"
#import "AFServiceResponse.h"

typedef void(^CompletionBlock)(NSDictionary *resultDic);

Expand Down Expand Up @@ -99,8 +101,8 @@ typedef enum {
*
* @param infoStr 授权请求信息字串
* @param schemeStr 调用授权的app注册在info.plist中的scheme
* @param completionBlock 授权结果回调,若在授权过程中,调用方应用被系统终止,则此block无效,
需要调用方在appDelegate中调用processAuth_V2Result:standbyCallback:方法获取授权结果
* @param completionBlock 授权结果回调,需要调用方在appDelegate中调用processAuth_V2Result:standbyCallback:方法获取授权结果
* 若在授权过程中,调用方应用被系统终止则此block无效(此时会调用'processAuth_V2Result:standbyCallback:'传入的standbyCallback)
*/
- (void)auth_V2WithInfo:(NSString *)infoStr
fromScheme:(NSString *)schemeStr
Expand All @@ -110,7 +112,7 @@ typedef enum {
* 处理支付宝app授权后跳回商户app携带的授权结果Url
*
* @param resultUrl 支付宝app返回的授权结果url
* @param completionBlock 授权结果回调
* @param completionBlock 授权结果回调,用于处理跳转支付宝授权过程中商户APP被系统终止的情况
*/
- (void)processAuth_V2Result:(NSURL *)resultUrl
standbyCallback:(CompletionBlock)completionBlock;
Expand Down Expand Up @@ -200,4 +202,22 @@ typedef enum {
* @param block 更新请求结果回调
*/
- (void)fetchSdkConfigWithBlock:(void(^)(BOOL success))block;


typedef void(^APLogBlock)(NSString *log);

/**
* 接收AlipaySDK的log信息
*
* @param logBlock 打印log的回调block
*/
+ (void)startLogWithBlock:(APLogBlock)logBlock;

/**
* 停止输出log,会释放logBlock
*
*
*/
+ (void)stopLog;

@end
Loading