Commit e67a4058 by houweibin

1,订单支付补完

parent 159e0c9f
...@@ -316,6 +316,7 @@ ...@@ -316,6 +316,7 @@
C0F5869B1E25D05F001248E2 /* KWMProductDetailView.m in Sources */ = {isa = PBXBuildFile; fileRef = C0F5869A1E25D05F001248E2 /* KWMProductDetailView.m */; }; C0F5869B1E25D05F001248E2 /* KWMProductDetailView.m in Sources */ = {isa = PBXBuildFile; fileRef = C0F5869A1E25D05F001248E2 /* KWMProductDetailView.m */; };
C0F5869D1E25D3B6001248E2 /* KWMProductDetailView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0F5869C1E25D3B6001248E2 /* KWMProductDetailView.xib */; }; C0F5869D1E25D3B6001248E2 /* KWMProductDetailView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0F5869C1E25D3B6001248E2 /* KWMProductDetailView.xib */; };
C0F586AE1E279574001248E2 /* KWMBottomView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0F586AD1E279574001248E2 /* KWMBottomView.xib */; }; C0F586AE1E279574001248E2 /* KWMBottomView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0F586AD1E279574001248E2 /* KWMBottomView.xib */; };
C0FBD88E1F049D510009E375 /* KWMOrderPaid.m in Sources */ = {isa = PBXBuildFile; fileRef = C0FBD88D1F049D510009E375 /* KWMOrderPaid.m */; };
C0FC278E1D9B73B000C5CFFE /* KWMGiftCardCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C0FC278D1D9B73B000C5CFFE /* KWMGiftCardCell.m */; }; C0FC278E1D9B73B000C5CFFE /* KWMGiftCardCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C0FC278D1D9B73B000C5CFFE /* KWMGiftCardCell.m */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
...@@ -880,6 +881,8 @@ ...@@ -880,6 +881,8 @@
C0F5869A1E25D05F001248E2 /* KWMProductDetailView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMProductDetailView.m; sourceTree = "<group>"; }; C0F5869A1E25D05F001248E2 /* KWMProductDetailView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMProductDetailView.m; sourceTree = "<group>"; };
C0F5869C1E25D3B6001248E2 /* KWMProductDetailView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMProductDetailView.xib; sourceTree = "<group>"; }; C0F5869C1E25D3B6001248E2 /* KWMProductDetailView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMProductDetailView.xib; sourceTree = "<group>"; };
C0F586AD1E279574001248E2 /* KWMBottomView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMBottomView.xib; sourceTree = "<group>"; }; C0F586AD1E279574001248E2 /* KWMBottomView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMBottomView.xib; sourceTree = "<group>"; };
C0FBD88C1F049D510009E375 /* KWMOrderPaid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMOrderPaid.h; sourceTree = "<group>"; };
C0FBD88D1F049D510009E375 /* KWMOrderPaid.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMOrderPaid.m; sourceTree = "<group>"; };
C0FC278C1D9B73B000C5CFFE /* KWMGiftCardCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMGiftCardCell.h; sourceTree = "<group>"; }; C0FC278C1D9B73B000C5CFFE /* KWMGiftCardCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMGiftCardCell.h; sourceTree = "<group>"; };
C0FC278D1D9B73B000C5CFFE /* KWMGiftCardCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMGiftCardCell.m; sourceTree = "<group>"; }; C0FC278D1D9B73B000C5CFFE /* KWMGiftCardCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMGiftCardCell.m; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
...@@ -1242,11 +1245,13 @@ ...@@ -1242,11 +1245,13 @@
C034E6C21D6AECF9006EE129 /* Model */ = { C034E6C21D6AECF9006EE129 /* Model */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
C034E6CC1D6AEE20006EE129 /* DAO */,
C0FBD88C1F049D510009E375 /* KWMOrderPaid.h */,
C0FBD88D1F049D510009E375 /* KWMOrderPaid.m */,
C03120A81EF2AC5A00E49EFA /* KWMWechatPayData.h */, C03120A81EF2AC5A00E49EFA /* KWMWechatPayData.h */,
C03120A91EF2AC5A00E49EFA /* KWMWechatPayData.m */, C03120A91EF2AC5A00E49EFA /* KWMWechatPayData.m */,
C091EE311DDB1FC500A382B9 /* KWMAppVersion.h */, C091EE311DDB1FC500A382B9 /* KWMAppVersion.h */,
C091EE321DDB1FC500A382B9 /* KWMAppVersion.m */, C091EE321DDB1FC500A382B9 /* KWMAppVersion.m */,
C034E6CC1D6AEE20006EE129 /* DAO */,
C034E6C61D6AED1F006EE129 /* KWMUser.h */, C034E6C61D6AED1F006EE129 /* KWMUser.h */,
C034E6C71D6AED1F006EE129 /* KWMUser.m */, C034E6C71D6AED1F006EE129 /* KWMUser.m */,
807AF49E1DC984950000A326 /* KWMProducts.h */, 807AF49E1DC984950000A326 /* KWMProducts.h */,
...@@ -2536,6 +2541,7 @@ ...@@ -2536,6 +2541,7 @@
C0F4AF481DF110F000BDA719 /* KWMProductResult.m in Sources */, C0F4AF481DF110F000BDA719 /* KWMProductResult.m in Sources */,
C0E8AE0C1D7D503600C193DC /* KWMPaySuccessVC.m in Sources */, C0E8AE0C1D7D503600C193DC /* KWMPaySuccessVC.m in Sources */,
C0392DBD1DCC786F0051AC8E /* KWMShippingVC.m in Sources */, C0392DBD1DCC786F0051AC8E /* KWMShippingVC.m in Sources */,
C0FBD88E1F049D510009E375 /* KWMOrderPaid.m in Sources */,
807AF4A61DC984950000A326 /* KWMDataProduct.m in Sources */, 807AF4A61DC984950000A326 /* KWMDataProduct.m in Sources */,
80C8014F1D78134800002306 /* KWMTBVSectionHeardView.m in Sources */, 80C8014F1D78134800002306 /* KWMTBVSectionHeardView.m in Sources */,
C034E7C21D6B0B62006EE129 /* KWMMineVC.m in Sources */, C034E7C21D6B0B62006EE129 /* KWMMineVC.m in Sources */,
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#import "KWMCartResult.h" #import "KWMCartResult.h"
#import "KWMCheckoutPayResult.h" #import "KWMCheckoutPayResult.h"
#import "KWMWechatPayData.h" #import "KWMWechatPayData.h"
#import "KWMOrderPaid.h"
...@@ -264,4 +265,12 @@ ...@@ -264,4 +265,12 @@
success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure; failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure;
/**
* 通过checkout_token查询shopify订单API
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) appOrderQuery:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure;
@end @end
...@@ -795,7 +795,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651"; ...@@ -795,7 +795,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
- (NSURLSessionDataTask *) wechatPayUnifiedOrder:(NSDictionary *)parameters - (NSURLSessionDataTask *) wechatPayUnifiedOrder:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{ failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{
NSString *apiPath = @"https://peter.tofnews.com/wechatpay/app/unified_order"; NSString *apiPath = @"https://liang.tofnews.com/wechatpay/app/unified_order";
return [self startSessionTask:KWMHTTPMethodPOST return [self startSessionTask:KWMHTTPMethodPOST
apiPath:apiPath apiPath:apiPath
...@@ -821,7 +821,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651"; ...@@ -821,7 +821,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
- (NSURLSessionDataTask *) aliPayUnifiedOrder:(NSDictionary *)parameters - (NSURLSessionDataTask *) aliPayUnifiedOrder:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{ failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{
NSString *apiPath = @"https://peter.tofnews.com/alipay/app/unified_order"; NSString *apiPath = @"https://liang.tofnews.com/alipay/app/unified_order";
return [self startSessionTask:KWMHTTPMethodPOST return [self startSessionTask:KWMHTTPMethodPOST
apiPath:apiPath apiPath:apiPath
...@@ -835,7 +835,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651"; ...@@ -835,7 +835,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
- (NSURLSessionDataTask *) wechatPayOrderQuery:(NSDictionary *)parameters - (NSURLSessionDataTask *) wechatPayOrderQuery:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{ failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{
NSString *apiPath = @"https://peter.tofnews.com/wechatpay/order/query"; NSString *apiPath = @"https://liang.tofnews.com/wechatpay/order/query";
return [self startSessionTask:KWMHTTPMethodPOST return [self startSessionTask:KWMHTTPMethodPOST
apiPath:apiPath apiPath:apiPath
...@@ -849,7 +849,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651"; ...@@ -849,7 +849,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
- (NSURLSessionDataTask *) aliPayOrderQuery:(NSDictionary *)parameters - (NSURLSessionDataTask *) aliPayOrderQuery:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{ failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{
NSString *apiPath = @"https://peter.tofnews.com/alipay/order/query"; NSString *apiPath = @"https://liang.tofnews.com/alipay/order/query";
return [self startSessionTask:KWMHTTPMethodPOST return [self startSessionTask:KWMHTTPMethodPOST
apiPath:apiPath apiPath:apiPath
...@@ -860,6 +860,35 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651"; ...@@ -860,6 +860,35 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
failure:failure]; failure:failure];
} }
/**
* 通过checkout_token查询shopify订单API
* checkout_token shopify订单token
* sign 签名验证
* 签名规则
* str_sign = checkout_token=5173547165345&key=bd3f58f5cd3d7a217ac8c8e655ab52f8";
* sign = md5(base64_encode($str_sign));
*
* @return NSURLSessionDataTask
*/
- (NSURLSessionDataTask *) appOrderQuery:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMCheckoutPayResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{
NSString *apiPath = @"https://liang.tofnews.com/app/order/query";
return [self startSessionTask:KWMHTTPMethodPOST
apiPath:apiPath
parameters:parameters
result:[KWMCheckoutPayResult class]
model:[KWMOrderPaid class]
success:success
failure:failure];
}
@end @end
//
// KWMOrderPaid.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/27.
// Copyright © 2017年 kollway. All rights reserved.
// 查询支付结果API返回的model
#import "KWMBaseModel.h"
@interface KWMOrderPaid : KWMBaseModel
/**生成的订单ID*/
@property (nonatomic) NSNumber * _Nullable orderId;
@end
//
// KWMOrderPaid.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/27.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMOrderPaid.h"
@implementation KWMOrderPaid
@end
...@@ -172,8 +172,11 @@ static NSString * idStr = @"KWMNewGoodsCell"; ...@@ -172,8 +172,11 @@ static NSString * idStr = @"KWMNewGoodsCell";
//点击婴儿 //点击婴儿
- (IBAction)onClickBabyBtn:(id)sender { - (IBAction)onClickBabyBtn:(id)sender {
if([TestModel isEqualToString:@"YES"]){ if([TestModel isEqualToString:@"YES"]){
KWMSelectedGoodsVC * selectedGoodsVC = (KWMSelectedGoodsVC *)[KWMBaseVC findControllerBy:[KWMSelectedGoodsVC kwmTag] fromStoryboard:@"New"]; // KWMSelectedGoodsVC * selectedGoodsVC = (KWMSelectedGoodsVC *)[KWMBaseVC findControllerBy:[KWMSelectedGoodsVC kwmTag] fromStoryboard:@"New"];
[self.navigationController pushViewController:selectedGoodsVC animated:YES]; // [self.navigationController pushViewController:selectedGoodsVC animated:YES];
KWMProductDetailVC *vc = (KWMProductDetailVC *)[KWMBaseVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"];
vc.productId = @(11406082255);
[self.navigationController pushViewController:vc animated:YES];
return; return;
} }
[self JumpToNewSelectedVCWith:self.btnBaby.titleLabel.text type:0]; [self JumpToNewSelectedVCWith:self.btnBaby.titleLabel.text type:0];
......
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
- (void)viewWillAppear:(BOOL)animated{ - (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated]; [super viewWillAppear:animated];
[self validateOrderPayResult];
[self initDefaultData]; [self initDefaultData];
} }
...@@ -51,16 +50,21 @@ ...@@ -51,16 +50,21 @@
self.payType = [self.userDao.currencyCode isEqualToString:@"EUR"]?TypeWebpay:TypeNone; self.payType = [self.userDao.currencyCode isEqualToString:@"EUR"]?TypeWebpay:TypeNone;
self.beforePayData = [KWMBeforePayData new]; self.beforePayData = [KWMBeforePayData new];
//支付成功回调广播接收者 ##通过广播接受appdelegate中的支付回调。 //支付成功回调广播接收者 ##通过广播接受appdelegate中的支付回调。
//app active回调广播接受者 ##判断订单支付状态.
NSNotificationCenter *notifi = [NSNotificationCenter defaultCenter]; NSNotificationCenter *notifi = [NSNotificationCenter defaultCenter];
[notifi addObserver:self selector:@selector(paySuccess) name:KWMPaySuccess object:nil]; [notifi addObserver:self selector:@selector(paySuccess) name:KWMPaySuccess object:nil];
[notifi addObserver:self selector:@selector(requestOrderPayResult) name:UIApplicationDidBecomeActiveNotification object:nil];
} }
-(void)dealloc{ -(void)dealloc{
//注销支付成功广播接收者 //注销广播接收者
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter removeObserver:self [notificationCenter removeObserver:self
name:KWMPaySuccess name:KWMPaySuccess
object:nil]; object:nil];
[notificationCenter removeObserver:self
name:UIApplicationDidBecomeActiveNotification
object:nil];
} }
-(void)setPayType:(KWMPayType)payType{ -(void)setPayType:(KWMPayType)payType{
...@@ -561,6 +565,8 @@ ...@@ -561,6 +565,8 @@
if(this.checkout.shippingAddress && !this.checkout.shippingRate) { if(this.checkout.shippingAddress && !this.checkout.shippingRate) {
[this requestShippingData]; [this requestShippingData];
} }
//排除已被支付的checkout的可能性
[this requestOrderPayResult];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[this hideLoading]; [this hideLoading];
[this showError:error]; [this showError:error];
...@@ -610,18 +616,31 @@ ...@@ -610,18 +616,31 @@
}]; }];
} }
-(void)validateOrderPayResult{ -(void)requestOrderPayResult{
//微信支付,用户支付后,当用户没有点击完成按钮,而是直接使用home键,或者点击状态栏左上角返回APP订单页面时,微信的回调不会调用,而很容易出现订单结果丢失的情况,所以需要再确认一次订单是否完成。 //微信支付,用户支付后,当用户没有点击完成按钮,而是直接使用home键,或者点击状态栏左上角返回APP订单页面时,微信的回调不会调用,而很容易出现订单结果丢失的情况,所以需要再确认一次订单是否完成。
//支付宝暂时没有这种问题。 //支付宝暂时没有这种问题。
//checkout与order暂无法直接关联,现该api一直返回未支付。 //另外用到的情况:上次被支付的订单,因某些突发原因没从缓存清除。
if(self.beforePayData && self.beforePayData.wechatPayData){ //if(self.beforePayData && self.beforePayData.wechatPayData && self.checkout){
if(self.checkout){
NSDictionary *parameters = [KWMPayUtil payResultParameters:self.checkout];
self.beforePayData.wechatPayData = nil; self.beforePayData.wechatPayData = nil;
__weak KWMBeforePayVC *weakSelf = self; __weak KWMBeforePayVC *weakSelf = self;
[self.client getCompletionStatusOfCheckoutWithToken:self.checkout.token completion:^(BUYStatus status, NSError * _Nullable error) { void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){
if (!error && status) { //[weakSelf showError:error];
};
void(^success)(NSURLSessionDataTask *,KWMCheckoutPayResult *) = ^(NSURLSessionDataTask *task,KWMCheckoutPayResult *result){
if(!result){
return;
}
if(!result.code || result.code.integerValue != 1000){
return;
}
if(result.data){
KWMOrderPaid *data = (KWMOrderPaid *)result.data;
[weakSelf paySuccess]; [weakSelf paySuccess];
} }
}]; };
// [self.api appOrderQuery:parameters success:success failure:failure];
} }
} }
...@@ -688,8 +707,6 @@ ...@@ -688,8 +707,6 @@
-(void)goToWebPay{ -(void)goToWebPay{
KWMCheckoutWebViewVC *checkoutVC = (KWMCheckoutWebViewVC *)[KWMBaseVC findControllerBy:[KWMCheckoutWebViewVC kwmTag] fromStoryboard:@"ShopCart"]; KWMCheckoutWebViewVC *checkoutVC = (KWMCheckoutWebViewVC *)[KWMBaseVC findControllerBy:[KWMCheckoutWebViewVC kwmTag] fromStoryboard:@"ShopCart"];
checkoutVC.payURL = self.checkout.webCheckoutURL; checkoutVC.payURL = self.checkout.webCheckoutURL;
// checkoutVC.payURL = [NSURL URLWithString:@"http://wxpay.wxutil.com/mch/pay/h5.v2.php"];
[self.navigationController pushViewController:checkoutVC animated:YES]; [self.navigationController pushViewController:checkoutVC animated:YES];
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
self.title = @"支付成功"; self.title = @"支付成功";
[[KWMShopCartData alloc] removeAllItems]; [[KWMShopCartData alloc] removeAllItems];
[self.userDao deleteCheckoutCache];
[self initButton]; [self initButton];
} }
......
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
//构建支付宝下单数据 //构建支付宝下单数据
+ (NSDictionary *) aliPayParameters:(BUYCheckout *)checkout; + (NSDictionary *) aliPayParameters:(BUYCheckout *)checkout;
//构建支付结果查询数据
+(NSDictionary *)payResultParameters:(BUYCheckout *)checkout;
//调用微信SDK //调用微信SDK
+ (void)weChatPay:(KWMWechatPayData *)wechatData; + (void)weChatPay:(KWMWechatPayData *)wechatData;
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
case TypeAlipay: case TypeAlipay:
payTypeString = @"支付宝支付"; payTypeString = @"支付宝支付";
break; break;
case TypeWebpay:
payTypeString = @"网页支付";
} }
return payTypeString; return payTypeString;
} }
...@@ -33,8 +35,8 @@ ...@@ -33,8 +35,8 @@
+(NSDictionary *)wechatPayParameters:(BUYCheckout *)checkout{ +(NSDictionary *)wechatPayParameters:(BUYCheckout *)checkout{
//这是测试商店的单,先用来测试 //这是测试商店的单,先用来测试
#if DEBUG #if DEBUG
NSString *checkout_token = @"bfa0423b2b51657098d581a93e78bc00"; NSString *checkout_token = checkout.token;
NSString *total_price = @"127.00"; NSString *total_price = [NSString stringWithFormat:@"%.2f",checkout.totalPrice.floatValue];
//先写test,后面改成正式的订单描述 //先写test,后面改成正式的订单描述
NSString *subject = @"test"; NSString *subject = @"test";
#else #else
...@@ -62,8 +64,8 @@ ...@@ -62,8 +64,8 @@
+(NSDictionary *)aliPayParameters:(BUYCheckout *)checkout{ +(NSDictionary *)aliPayParameters:(BUYCheckout *)checkout{
//这是测试商店的单,先用来测试 //这是测试商店的单,先用来测试
#if DEBUG #if DEBUG
NSString *checkout_token = @"bfa0423b2b51657098d581a93e78bc00"; NSString *checkout_token = checkout.token;
NSString *total_price = @"127.00"; NSString *total_price = [NSString stringWithFormat:@"%.2f",checkout.totalPrice.floatValue];
NSString *subject = @"test"; NSString *subject = @"test";
#else #else
NSString *checkout_token = checkout.token; NSString *checkout_token = checkout.token;
...@@ -85,6 +87,27 @@ ...@@ -85,6 +87,27 @@
return parameters; return parameters;
} }
//现在在两个地方会用到这条api
//1,支付后切换回到APP
//2,beforepay创建/复用旧checkout时,判断该checkout是否被支付了,但是之前没清空。
+(NSDictionary *)payResultParameters:(BUYCheckout *)checkout{
#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 *base64String = [KWMStringUtil BASE64:before_sign];
NSString *sign = [KWMStringUtil MD5:base64String];
NSDictionary *parameters = @{
@"checkout_token":checkout_token,
@"sign":sign
};
return parameters;
}
+(void)weChatPay:(KWMWechatPayData *)wechatData{ +(void)weChatPay:(KWMWechatPayData *)wechatData{
if(wechatData){ if(wechatData){
PayReq *request = [[PayReq alloc] init]; PayReq *request = [[PayReq alloc] init];
......
...@@ -60,23 +60,22 @@ ...@@ -60,23 +60,22 @@
#define User_Pay_KEY @"bd3f58f5cd3d7a217ac8c8e655ab52f8" #define User_Pay_KEY @"bd3f58f5cd3d7a217ac8c8e655ab52f8"
//// //测试
////测试 #define TestModel @"YES"
//#define TestModel @"YES"
//
////Shopify对应的key(测试用)
//#define Shopify_SHOP_DOMAIN @"cemarose-dev.myshopify.com"
//#define Shopify_API_KEY @"85287d2c9762a425bacd31424928a4e6"
//#define Shopify_APP_ID @"8"
//正式
#define TestModel @"NO"
//Shopify对应的key(正式 //Shopify对应的key(测试用
#define Shopify_SHOP_DOMAIN @"cemarose.myshopify.com" #define Shopify_SHOP_DOMAIN @"cemarose-test.myshopify.com"
#define Shopify_API_KEY @"c2f6fae97741ea6db4cad7ae8f70fef3" #define Shopify_API_KEY @"4f34b3c32f4297386fc4fdaee7ef2bce"
#define Shopify_APP_ID @"8" #define Shopify_APP_ID @"8"
////正式
//#define TestModel @"NO"
//
////Shopify对应的key(正式)
//#define Shopify_SHOP_DOMAIN @"cemarose.myshopify.com"
//#define Shopify_API_KEY @"c2f6fae97741ea6db4cad7ae8f70fef3"
//#define Shopify_APP_ID @"8"
//软键盘输入限制 //软键盘输入限制
#define NUM @"0123456789" #define NUM @"0123456789"
#define ALPHA @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" #define ALPHA @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
......
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