Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
ios1x
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cemarose
ios1x
Commits
b582b8b7
Commit
b582b8b7
authored
7 years ago
by
houweibin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加支付失败弹窗
parent
c5d6da09
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
5 deletions
+78
-5
KWMCheckoutPayResult.h
iCemarose/Class/Api/KWMCheckoutPayResult.h
+6
-0
KWMBaseVC.m
iCemarose/Class/UI/KWMBaseVC.m
+3
-0
KWMBeforePayVC.m
iCemarose/Class/UI/ShopCart/KWMBeforePayVC.m
+8
-5
KWMPayUtil.h
iCemarose/Class/Util/KWMPayUtil.h
+2
-0
KWMPayUtil.m
iCemarose/Class/Util/KWMPayUtil.m
+59
-0
No files found.
iCemarose/Class/Api/KWMCheckoutPayResult.h
View file @
b582b8b7
...
...
@@ -30,6 +30,9 @@
|code|int|1006|订单已支付完成|
|code|int|1007|签名验证失败|
|code|int|1008|订单查询失败|
|code|int|1009|订单创建失败|
|code|int|1010|必要参数缺失|
|code|int|1012|商品数量不足|
*/
@property
(
nonatomic
)
NSNumber
<
Optional
>
*
code
;
...
...
@@ -39,4 +42,7 @@
//数据--存放解析后的model。ps:只有当微信支付下单返回结果状态为成功时,message key里的数据才会是wechat pay model的数据,此时,会将message里的数据转换为对应的model并存放到data里。
@property
(
nonatomic
)
id
<
Optional
>
data
;
//商品缺货时的variantId
@property
(
nonatomic
)
NSNumber
<
Optional
>
*
variantId
;
@end
This diff is collapsed.
Click to expand it.
iCemarose/Class/UI/KWMBaseVC.m
View file @
b582b8b7
...
...
@@ -276,6 +276,9 @@
}
-
(
void
)
showDialog
:
(
NSString
*
)
message
{
if
([
KWMStringUtil
isEmpty
:
message
]){
return
;
}
PSPDFAlertView
*
alertView
=
[[
PSPDFAlertView
alloc
]
initWithTitle
:
message
];
[
alertView
addButtonWithTitle
:
@"确定"
block
:
nil
];
[
alertView
show
];
...
...
This diff is collapsed.
Click to expand it.
iCemarose/Class/UI/ShopCart/KWMBeforePayVC.m
View file @
b582b8b7
...
...
@@ -659,11 +659,12 @@
};
void
(
^
success
)(
NSURLSessionDataTask
*
,
KWMCheckoutPayResult
*
)
=
^
(
NSURLSessionDataTask
*
task
,
KWMCheckoutPayResult
*
result
){
[
weakSelf
hideLoading
];
if
(
!
result
){
if
(
!
(
result
&&
result
.
code
)
){
return
;
}
if
(
!
result
.
code
||
result
.
code
.
integerValue
!=
1000
){
NSLog
(
@"error: %@"
,
result
.
message
);
if
(
result
.
code
.
integerValue
!=
1000
){
NSString
*
message
=
[
KWMPayUtil
payErrorMessage
:
weakSelf
.
checkout
errorResult
:
result
];
[
weakSelf
showDialog
:
message
];
return
;
}
NSString
*
alipayData
=
(
NSString
*
)
result
.
message
;
...
...
@@ -694,10 +695,12 @@
};
void
(
^
success
)(
NSURLSessionDataTask
*
,
KWMCheckoutPayResult
*
)
=
^
(
NSURLSessionDataTask
*
task
,
KWMCheckoutPayResult
*
result
){
[
weakSelf
hideLoading
];
if
(
!
result
){
if
(
!
(
result
&&
result
.
code
)
){
return
;
}
if
(
!
result
.
code
||
result
.
code
.
integerValue
!=
1000
){
if
(
result
.
code
.
integerValue
!=
1000
){
NSString
*
message
=
[
KWMPayUtil
payErrorMessage
:
weakSelf
.
checkout
errorResult
:
result
];
[
weakSelf
showDialog
:
message
];
return
;
}
if
(
result
.
data
){
...
...
This diff is collapsed.
Click to expand it.
iCemarose/Class/Util/KWMPayUtil.h
View file @
b582b8b7
...
...
@@ -34,6 +34,8 @@
//调用支付宝SDK
+
(
void
)
aliPay
:(
NSString
*
)
alipayData
callback
:(
CompletionBlock
)
callback
;
//支付失败提示信息
+
(
NSString
*
)
payErrorMessage
:(
BUYCheckout
*
)
checkout
errorResult
:(
KWMCheckoutPayResult
*
)
errorResult
;
@end
This diff is collapsed.
Click to expand it.
iCemarose/Class/Util/KWMPayUtil.m
View file @
b582b8b7
...
...
@@ -123,4 +123,63 @@
}
}
/*
|code|int|1000|正常响应|
|code|int|1001|订单检索失败,未找到相应的订单数据|
|code|int|1002|请求的总金额与订单中不一致|
|code|int|1003|货币转换失败|
|code|int|1004|服务器端未开通店铺|
|code|int|1005|支付网关参数未设置|
|code|int|1006|订单已支付完成|
|code|int|1007|签名验证失败|
|code|int|1008|订单查询失败|
|code|int|1009|订单创建失败|
|code|int|1010|必要参数缺失|
|code|int|1012|商品数量不足|
*/
+
(
NSString
*
)
payErrorMessage
:(
BUYCheckout
*
)
checkout
errorResult
:(
KWMCheckoutPayResult
*
)
errorResult
{
if
(
!
errorResult
){
return
@""
;
}
if
(
errorResult
.
code
){
switch
(
errorResult
.
code
.
integerValue
)
{
case
1000
:
return
@""
;
case
1001
:
return
@"订单检索失败,未找到相应的订单数据"
;
case
1002
:
return
@"请求的总金额与订单中不一致"
;
case
1003
:
return
@"货币转换失败"
;
case
1004
:
return
@"服务器端未开通店铺"
;
case
1005
:
return
@"支付网关参数未设置"
;
case
1006
:
return
@"订单已支付完成"
;
case
1007
:
return
@"签名验证失败"
;
case
1008
:
return
@"订单查询失败"
;
case
1009
:
return
@"订单创建失败"
;
case
1010
:
return
@"必要参数缺失"
;
case
1012
:
if
(
!
(
checkout
&&
errorResult
.
variantId
)
){
return
@""
;
}
for
(
BUYCartLineItem
*
item
in
checkout
.
lineItemsArray
){
if
([
item
.
variantId
isEqualToNumber
:
errorResult
.
variantId
]){
NSString
*
message
=
[
NSString
stringWithFormat
:
@"商品“%@/%@”数量不足"
,
item
.
title
,
item
.
variantTitle
];
return
message
;
}
}
return
@"商品数量不足"
;
}
}
return
@""
;
}
@end
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment