Skip to content

Commit 1456b1c

Browse files
committed
支付宝 - 支付回调处理
1 parent 35701b2 commit 1456b1c

7 files changed

Lines changed: 35 additions & 1 deletion

File tree

Coding_iOS/AppDelegate.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,9 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl
287287
DebugLog(@"path: %@, params: %@", [url path], [url queryParams]);
288288
if ([url.absoluteString hasPrefix:kCodingAppScheme]) {
289289
NSDictionary *queryParams = [url queryParams];
290-
if (queryParams[@"email"] && queryParams[@"key"]) {//重置密码
290+
if ([url.host isEqualToString:@"safepay"]) {//支付宝支付
291+
[self p_handlePayURL:url];
292+
}else if (queryParams[@"email"] && queryParams[@"key"]) {//重置密码
291293
[self showPasswordWithURL:url];
292294
}else if ([queryParams[@"type"] isEqualToString:@"tweet"]){//发冒泡
293295
if ([Login isLogin]) {
@@ -306,6 +308,13 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl
306308
}
307309
}
308310

311+
- (void)p_handlePayURL:(NSURL *)url{
312+
UIViewController *vc = [BaseViewController presentingVC];
313+
if ([vc respondsToSelector:@selector(handlePayURL:)]) {
314+
[vc performSelector:@selector(handlePayURL:) withObject:url];
315+
}
316+
}
317+
309318
- (BOOL)showPasswordWithURL:(NSURL *)url{
310319
PasswordType type;
311320
NSString *email, *key;

Coding_iOS/Controllers/Shop/ExchangeGoodsViewController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@
1313

1414
@property(nonatomic , strong)ShopGoods *shopGoods;
1515

16+
- (void)handlePayURL:(NSURL *)url;
17+
1618
@end

Coding_iOS/Controllers/Shop/ExchangeGoodsViewController.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,13 @@ - (void)handleAliResult:(NSDictionary *)resultDic{
448448
[self goToAfterPay];
449449
}
450450

451+
- (void)handlePayURL:(NSURL *)url{
452+
__weak typeof(self) weakSelf = self;
453+
[[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
454+
[weakSelf handleAliResult:resultDic];
455+
}];
456+
}
457+
451458
- (void)goToAfterPay{
452459
UINavigationController *nav = self.navigationController;
453460
[nav popViewControllerAnimated:NO];

Coding_iOS/Controllers/Shop/ShopOrderViewController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@
1010

1111
@interface ShopOrderViewController : BaseViewController
1212

13+
- (void)handlePayURL:(NSURL *)url;
14+
1315
@end

Coding_iOS/Controllers/Shop/ShopOrderViewController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ - (void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel{
149149
}];
150150
}
151151

152+
- (void)handlePayURL:(NSURL *)url{
153+
ShopOrderListView *listView = (ShopOrderListView *)_myCarousel.currentItemView;
154+
[listView handlePayURL:url];
155+
}
156+
152157
- (void)dealloc
153158
{
154159
_myCarousel.dataSource = nil;

Coding_iOS/Views/TableListView/ShopOrderListView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@
1717

1818
- (void)reloadData;
1919

20+
- (void)handlePayURL:(NSURL *)url;
21+
2022
@end
2123

Coding_iOS/Views/TableListView/ShopOrderListView.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,13 @@ - (void)handleAliResult:(NSDictionary *)resultDic{
237237
}
238238
}
239239

240+
- (void)handlePayURL:(NSURL *)url{
241+
__weak typeof(self) weakSelf = self;
242+
[[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
243+
[weakSelf handleAliResult:resultDic];
244+
}];
245+
}
246+
240247
- (void)dealloc
241248
{
242249
_currentOrderCell = nil;

0 commit comments

Comments
 (0)