最近在做支付宝支付功能 ,本来以为会有很多很多坑,没想带后台数据支持后so easy!
所谓的后台支持就是:另外一种调用支付宝的支付方式,不用接支付宝SDK,具体的是后台的,只是在后台配置的时候,厚爱要麻烦一些,
前端只需要把小商品的唯一标识传给后台,然后就会生成一个:
scheme:
范例:
https://mapi.alipay.com/gateway.do?_input_charset=utf-8&access_info=%7B%22channel%22%3A%22WAP%22%7D¬ify_url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttp%2Fb2c.ezparking.com.cn%2Frtpi-service%2Falipay%2Fgateway.do&out_trade_no=45992553&partner=2088021659301977&payment_type=1&return_url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttp%2Fb2c.ezparking.com.cn%2Frtpi-service%2Falipay%2FpayReturnWap.do&seller_id=2088021659301977&service=alipay.wap.create.direct.pay.by.user&show_url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttp%2Fbook.ezparking.com.cn%2Fbook%2F&sign=26d6de4b79a53d49659b9be6724148bc&sign_type=MD5&subject=%E7%BA%A6%E5%81%9C%E8%BD%A6&total_fee=10.00
然后就通过webView加载就行了:
_webView = [[UIWebView alloc]initWithFrame:self.view.bounds];
_webView.delegate = self;
_webView.scalesPageToFit = YES;
[self.view addSubview:_webView];
NSURLRequest *request = [[NSURLRequest alloc]initWithURL:[NSURL URLWithString:self.strUrl]];
[_webView loadRequest:request];
顺便说一些交互的东西:
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
self.title = [_webView stringByEvaluatingJavaScriptFromString:@"document.title"];
}
再然后只需要在delegate的这个方法里面直接发一个支付结果的通知就可以了!
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
LogPark(@"%@",url.absoluteString);
NSString *urlStr = url.absoluteString;
if ([urlStr hasPrefix:@"yoparking://order"]) {
BOOL isSuccess = [urlStr containsString:@"is_success=T"];
NSLog(@"发通知");
[[NSNotificationCenter defaultCenter] postNotificationName:@"paySussecc" object:nil];
return isSuccess;
}
}