Commit 64bfda26 by houweibin

1,查询订单支付api,添加参数out_trade_no

2,分类页默认选中修改
parent 93b80362
......@@ -874,9 +874,10 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
/**
* 通过checkout_token查询shopify订单API
* @param checkout_token shopify订单token
* @param out_trade_no 订单支付编号
* @param sign 签名验证
* 签名规则:
* str_sign = checkout_token=5173547165345&key=bd3f58f5cd3d7a217ac8c8e655ab52f8";
* str_sign = checkout_token=5173547165345&out_trade_no=201708011602269375&key=bd3f58f5cd3d7a217ac8c8e655ab52f8";
* sign = md5(base64_encode($str_sign));
*/
- (NSURLSessionDataTask *) appOrderQuery:(NSDictionary *)parameters
......
......@@ -14,4 +14,6 @@
@property (nonatomic) KWMWechatPayData *wechatPayData;
@property (nonatomic) NSString *outTradeNo;
@end
......@@ -26,6 +26,7 @@
@property (nonatomic) NSString * _Nullable package;
/**时间戳*/
@property (nonatomic) NSInteger timestamp;
/**微信订单编号*/
@property (nonatomic) NSString * _Nullable outTradeNo;
@end
......@@ -124,7 +124,7 @@
return m;
}];
self.selectedCategory = self.categories.firstObject;
NSIndexPath * path = [NSIndexPath indexPathForItem:1 inSection:0];
NSIndexPath * path = [NSIndexPath indexPathForItem:0 inSection:0];
[self.tbvLeftCategory selectRowAtIndexPath:path animated:YES scrollPosition:UITableViewScrollPositionTop];
}
......
......@@ -167,7 +167,11 @@ typedef enum{
#pragma mark - KWMMenuDelegate
-(void)kwm_onClickHotMenu{
if([TestModel isEqualToString:@"YES"]){
[self openURLWithString:[NSString stringWithFormat:@"https://cemarose.myshopify.com/products/%@",@"17618-01"]];
}else{
[self openURLWithString:@"https://cemarose.myshopify.com/collections/new?title=最新单品"];
}
}
-(void)kwm_onClickNewMenu{
......
......@@ -570,8 +570,6 @@
if(this.checkout.shippingAddress && !this.checkout.shippingRate) {
[this requestShippingData];
}
//排除已被支付的checkout的可能性
[this requestOrderPayResult];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[this hideLoading];
[this showError:error];
......@@ -622,13 +620,11 @@
}
-(void)requestOrderPayResult{
//微信支付,用户支付后,当用户没有点击完成按钮,而是直接使用home键,或者点击状态栏左上角返回APP订单页面时,微信的回调不会调用,而很容易出现订单结果丢失的情况,所以需要再确认一次订单是否完成。
//微信支付,用户支付后,当用户没有点击完成按钮,而是直接使用home键,或者点击状态栏左上角返回APP订单页面时,微信的回调不会调用,而很容易出现本地订单结果回调丢失的情况,所以需要再确认一次订单是否完成。
//支付宝暂时没有这种问题。
//另外用到的情况:上次被支付的订单,因某些突发原因没从缓存清除。
//if(self.beforePayData && self.beforePayData.wechatPayData && self.checkout){
if(self.checkout){
NSDictionary *parameters = [KWMPayUtil payResultParameters:self.checkout];
self.beforePayData.wechatPayData = nil;
if(self.beforePayData && ![KWMStringUtil isEmpty:self.beforePayData.outTradeNo] && self.checkout){
NSDictionary *parameters = [KWMPayUtil payResultParameters:self.checkout tradeNo:self.beforePayData.outTradeNo];
self.beforePayData.outTradeNo = @"";
__weak KWMBeforePayVC *weakSelf = self;
void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){
//[weakSelf showError:error];
......@@ -641,7 +637,7 @@
return;
}
if(result.data){
KWMOrderPaid *data = (KWMOrderPaid *)result.data;
//KWMOrderPaid *data = (KWMOrderPaid *)result.data;
[weakSelf paySuccess];
}
};
......@@ -706,7 +702,7 @@
if(result.data){
KWMWechatPayData *data = (KWMWechatPayData *)result.data;
[KWMPayUtil weChatPay:data];
weakSelf.beforePayData.wechatPayData = data;
weakSelf.beforePayData.outTradeNo = data.outTradeNo;
}
};
[self.api wechatPayUnifiedOrder:parameters success:success failure:failure];
......
......@@ -26,7 +26,7 @@
+ (NSDictionary *) aliPayParameters:(BUYCheckout *)checkout;
//构建支付结果查询数据
+(NSDictionary *)payResultParameters:(BUYCheckout *)checkout;
+(NSDictionary *)payResultParameters:(BUYCheckout *)checkout tradeNo:(NSString *)tradeNo;
//调用微信SDK
+ (void)weChatPay:(KWMWechatPayData *)wechatData;
......
......@@ -81,22 +81,21 @@
return parameters;
}
//现在在两个地方会用到这条api
//1,支付后切换回到APP
//2,beforepay创建/复用旧checkout时,判断该checkout是否被支付了,但是之前没清空。
+(NSDictionary *)payResultParameters:(BUYCheckout *)checkout{
//微信支付后直接切换回到APP会调用此方法
+(NSDictionary *)payResultParameters:(BUYCheckout *)checkout tradeNo:(NSString *)tradeNo{
#if DEBUG
NSString *checkout_token = checkout.token;
#else
NSString *checkout_token = checkout.token;
#endif
NSString *before_sign = [NSString stringWithFormat:@"checkout_token=%@&key=%@",
checkout_token,User_Pay_KEY];
NSString *out_trade_no = tradeNo?:@"";
NSString *before_sign = [NSString stringWithFormat:@"checkout_token=%@&out_trade_no=%@&key=%@",
checkout_token,out_trade_no,User_Pay_KEY];
NSString *base64String = [KWMStringUtil BASE64:before_sign];
NSString *sign = [KWMStringUtil MD5:base64String];
NSDictionary *parameters = @{
@"checkout_token":checkout_token,
@"out_trade_no":out_trade_no,
@"sign":sign
};
return parameters;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment