Skip to content

Commit

Permalink
v1.0.1 - bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderZhuXH committed Mar 11, 2018
1 parent 071ebe8 commit 54acb14
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 36 deletions.
2 changes: 1 addition & 1 deletion XHPayKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "XHPayKit"
s.version = "1.0.0"
s.version = "1.0.1"
s.summary = "不用官方SDK实现微信、支付宝支付."
s.homepage = "https://github.com/CoderZhuXH/XHPayKit"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand Down
4 changes: 2 additions & 2 deletions XHPayKit/XHPayKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// Copyright © 2018年 it7090.com. All rights reserved.
// 代码地址:https://github.com/CoderZhuXH/XHPayKit

// 版本:1.0.0
// 发布:2018.02.23
// 版本:1.0.1
// 发布:2018.03.11

// 如果你在使用过程中出现bug,请及时以下面任意一种方式联系我,我会及时修复bug并帮您解决问题。
// QQ交流群:537476189
Expand Down
4 changes: 2 additions & 2 deletions XHPayKit/XHPayKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ -(void)alipayOrder:(NSString *)orderStr fromScheme:(NSString *)schemeStr complet
}
NSDictionary *dict = @{@"fromAppUrlScheme":schemeStr,@"requestType":@"SafePay",@"dataString":orderStr};
NSString *dictEncodeString = dict.xh_jsonString.xh_URLEncodedString;
NSString *openUrl = [NSString stringWithFormat:@"%@%@%@",AliUrlPrefix,@"alipayclient/?",dictEncodeString];
NSString *openUrl = [NSString stringWithFormat:@"%@%@%@",AliUrlPrefix,AliUrlClient,dictEncodeString];
if(completedBlock){
self.completedBlock = [completedBlock copy];
}
Expand All @@ -89,7 +89,7 @@ -(BOOL)handleOpenURL:(NSURL *)url{
if(self.completedBlock) self.completedBlock(resultDict);
return YES;
}
if ([urlString rangeOfString:self.wxAppid].location != NSNotFound){
if (self.wxAppid && [urlString rangeOfString:self.wxAppid].location != NSNotFound){
NSArray *retArray = [urlString componentsSeparatedByString:@"&"];
NSInteger errCode = -1;
NSString *errStr = @"普通错误";
Expand Down
8 changes: 6 additions & 2 deletions XHPayKit/XHPayKitConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
#define XHPayKitLog(...)
#endif

#define AliUrlPrefix [NSString stringWithFormat:@"alipay%@",@"://"]
#define WxUrlPrefix [NSString stringWithFormat:@"weixin%@",@"://"]
#define AliUrlSign @"alipay"
#define AliUrlPrefix [NSString stringWithFormat:@"%@%@",AliUrlSign,@"://"]
#define AliUrlClient [NSString stringWithFormat:@"%@%@",AliUrlSign,@"client/?"]

#define WxUrlSign @"weixin"
#define WxUrlPrefix [NSString stringWithFormat:@"%@%@",WxUrlSign,@"://"]



13 changes: 8 additions & 5 deletions XHPayKit/XHPayWxReq.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@

#import <Foundation/Foundation.h>

//以下参数详细介绍见
//微信官方文档:https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_12&index=2

//发起微信支付的消息模型
@interface XHPayWxReq : NSObject
/** 由用户微信号和AppID组成的唯一标识,发送请求时第三方程序必须填写,用于校验微信用户是否换号登录*/
/** 微信开放平台审核通过的应用APPID*/
@property (nonatomic, copy) NSString* openID;
/** 商家向财付通申请的商家id */
/** 微信支付分配的商户号 */
@property (nonatomic, copy) NSString *partnerId;
/** 预支付订单 */
/** 微信返回的支付交易会话ID */
@property (nonatomic, copy) NSString *prepayId;
/** 随机串,防重发 */
@property (nonatomic, copy) NSString *nonceStr;
/** 时间戳,防重发 */
@property (nonatomic, assign) UInt32 timeStamp;
/** 商家根据财付通文档填写的数据和签名 */
/** 扩展字段,暂填写固定值Sign=WXPay */
@property (nonatomic, copy) NSString *package;
/** 商家根据微信开放平台文档对数据做的签名 */
/** 签名 */
@property (nonatomic, copy) NSString *sign;
@end

17 changes: 10 additions & 7 deletions XHPayKitExample/XHPayKitExample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *

//微信支付参数,下面7个参数,由后台签名订单后生成,并返回给客服端(与官方SDK一致)
//注意:请将下面参数设置为你自己真实订单签名后服务器返回参数,便可进行实际支付
//以下参数详细介绍见
//微信官方文档:https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_12&index=2

XHPayWxReq *req = [[XHPayWxReq alloc] init];
req.openID = @"";
req.partnerId = @"";
req.prepayId = @"";
req.nonceStr = @"";
req.timeStamp = 1518156229;
req.package = @"";
req.sign = @"";
req.openID = @"";//微信开放平台审核通过的应用APPID
req.partnerId = @"";//商户号
req.prepayId = @"";//交易会话ID
req.nonceStr = @"";//随机串,防重发
req.timeStamp = 1518156229;//时间戳,防重发
req.package = @"";// 扩展字段,暂填写固定值Sign=WXPay
req.sign = @"";//签名

//传入订单模型,拉起微信支付
[[XHPayKit defaultManager] wxpayOrder:req completed:^(NSDictionary *resultDict) {
Expand Down
3 changes: 3 additions & 0 deletions 审核防检测到支付功能版本/XHPKit/XHPKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
// Copyright © 2018年 it7090.com. All rights reserved.
// GitHub:https://github.com/CoderZhuXH

// 版本:1.0.1
// 发布:2018.03.11

// 如果你在使用过程中出现bug,请及时以下面任意一种方式联系我,我会及时修复bug并帮您解决问题。
// QQ交流群:537476189
// Email:[email protected]
Expand Down
4 changes: 2 additions & 2 deletions 审核防检测到支付功能版本/XHPKit/XHPKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ -(void)alipOrder:(NSString *)orderStr fromScheme:(NSString *)schemeStr completed
}
NSDictionary *dict = @{@"fromAppUrlScheme":schemeStr,@"requestType":@"SafePay",@"dataString":orderStr};
NSString *dictEncodeString = dict.xh_jsonString.xh_URLEncodedString;
NSString *openUrl = [NSString stringWithFormat:@"%@%@%@",AliUrlPrefix,@"alipayclient/?",dictEncodeString];
NSString *openUrl = [NSString stringWithFormat:@"%@%@%@",AliUrlPrefix,AliUrlClient,dictEncodeString];
if(completedBlock){
self.completedBlock = [completedBlock copy];
}
Expand All @@ -85,7 +85,7 @@ -(BOOL)handleOpenURL:(NSURL *)url{
if(self.completedBlock) self.completedBlock(resultDict);
return YES;
}
if ([urlString rangeOfString:self.wxAppid].location != NSNotFound){
if (self.wxAppid && [urlString rangeOfString:self.wxAppid].location != NSNotFound){
NSArray *retArray = [urlString componentsSeparatedByString:@"&"];
NSInteger errCode = -1;
NSString *errStr = @"普通错误";
Expand Down
8 changes: 6 additions & 2 deletions 审核防检测到支付功能版本/XHPKit/XHPKitConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
#define XHPKitLog(...)
#endif

#define AliUrlPrefix [NSString stringWithFormat:@"alipay%@",@"://"]
#define WxUrlPrefix [NSString stringWithFormat:@"weixin%@",@"://"]
#define AliUrlSign @"alipay"
#define AliUrlPrefix [NSString stringWithFormat:@"%@%@",AliUrlSign,@"://"]
#define AliUrlClient [NSString stringWithFormat:@"%@%@",AliUrlSign,@"client/?"]

#define WxUrlSign @"weixin"
#define WxUrlPrefix [NSString stringWithFormat:@"%@%@",WxUrlSign,@"://"]



14 changes: 8 additions & 6 deletions 审核防检测到支付功能版本/XHPKit/XHPWxReq.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@

#import <Foundation/Foundation.h>

//微信消息模型
//以下参数详细介绍见
//微信官方文档:https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_12&index=2

//发起微信支付的消息模型
@interface XHPWxReq : NSObject
/** 由用户微信号和AppID组成的唯一标识,发送请求时第三方程序必须填写,用于校验微信用户是否换号登录*/
/** 微信开放平台审核通过的应用APPID*/
@property (nonatomic, copy) NSString* openID;
/** 商家id */
/** 商户号 */
@property (nonatomic, copy) NSString *partnerId;
/** 订单id */
/** 交易会话ID */
@property (nonatomic, copy) NSString *prepayId;
/** 随机串,防重发 */
@property (nonatomic, copy) NSString *nonceStr;
/** 时间戳,防重发 */
@property (nonatomic, assign) UInt32 timeStamp;
/** 数据和签名 */
/** 扩展字段,暂填写固定值Sign=WXPay */
@property (nonatomic, copy) NSString *package;
/** 签名 */
@property (nonatomic, copy) NSString *sign;
@end

Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *

//微信支付参数,下面7个参数,由后台签名订单后生成,并返回给客服端(与官方SDK一致)
//注意:请将下面参数设置为你自己真实订单签名后服务器返回参数,便可进行实际支付
//以下参数详细介绍见
//微信官方文档:https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_12&index=2

XHPWxReq *req = [[XHPWxReq alloc] init];
req.openID = @"";
req.partnerId = @"";
req.prepayId = @"";
req.nonceStr = @"";
req.timeStamp = 1518156229;
req.package = @"";
req.sign = @"";
req.openID = @"";//微信开放平台审核通过的应用APPID
req.partnerId = @"";//商户号
req.prepayId = @"";//交易会话ID
req.nonceStr = @"";//随机串,防重发
req.timeStamp = 1518156229;//时间戳,防重发
req.package = @"";// 扩展字段,暂填写固定值Sign=WXPay
req.sign = @"";//签名

//传入订单模型,拉起微信支付
[[XHPKit defaultManager] wxpOrder:req completed:^(NSDictionary *resultDict) {
Expand Down

0 comments on commit 54acb14

Please sign in to comment.