1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/**
* partner:合做身份者ID,以 2088 开头由 16 位纯数字组成的字符串。
*
*/
#define kPartnerID @"xxx"
/**
* seller:支付宝收款帐号,手机号码或邮箱格式。
*/
#define kSellerAccount @"xxx"
/**
* 支付宝服务器主动通知商户 网站里指定的页面 http 路径。
*/
#define kNotifyURL @"xxx"
/**
* appSckeme:应用注册scheme,在Info.plist定义URLtypes,处理支付宝回调
*/
#define kAppScheme @"integratedAlipay"
/**
* private_key:商户方的私钥,pkcs8 格式。
*/
#define kPrivateKey @"xxx"
|
1
2
3
|
- (IBAction)payWithAli:(UIButton *)sender {
[AlipayRequestConfig alipayWithPartner:kPartnerID seller:kSellerAccount tradeNO:[AlipayToolKit genTradeNoWithTime] productName:@
"邮票"
productDescription:@
"全真邮票"
amount:@
"0.8"
notifyURL:kNotifyURL itBPay:@
"30m"
];
}
|
1
2
3
4
5
6
7
8
9
10
11
12
|
- (
BOOL
)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
//若是极简 SDK 不可用,会跳转支付宝钱包进行支付,须要将支付宝钱包的支付结果回传给 SDK if ([url.host isEqualToString:@"safepay"]) {
[[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
NSLog(@
"result = %@"
,resultDic);
}];
if
([url.host isEqualToString:@
"platformapi"
]){
//支付宝钱包快登受权返回 authCode
[[AlipaySDK defaultService] processAuthResult:url standbyCallback:^(NSDictionary *resultDic) {
NSLog(@
"result = %@"
,resultDic);
}];
}
return
YES;
}
|