美文网首页
关于京东支付

关于京东支付

作者: 灬白白 | 来源:发表于2016-12-14 09:34 被阅读64次

    关于京东支付其实不难,最难的在于京东官方没有给出文档。经过和后台的协商,所以参数都提交至后台加密。 京东支付实际上就是一个H5页面,只需要提交对应参数就行。

        NSMutableDictionary *formDic = [[NSMutableDictionary alloc] init];
        [formDic setObject:@"version" forKey:@"version"];
        [formDic setObject:self.sign forKey:@"sign"];
        [formDic setObject:@"merchant" forKey:@"merchant"];
        [formDic setObject:self.device forKey:@"device"];
        [formDic setObject:self.tradeNum forKey:@"tradeNum"];
        [formDic setObject:self.tradeName forKey:@"tradeName"];
        [formDic setObject:self.tradeTime forKey:@"tradeTime"];
        [formDic setObject:self.amount forKey:@"amount"];
        [formDic setObject:self.orderType forKey:@"orderType"];
        [formDic setObject:self.currency forKey:@"currency"];
        [formDic setObject:self.callbackUrl forKey:@"callbackUrl"];
        [formDic setObject:self.notifyUrl forKey:@"notifyUrl"];
        [formDic setObject:self.userType forKey:@"userType"];
        [formDic setObject:self.userId forKey:@"userId"];
        [formDic setObject:self.orderGoodsNum forKey:@"orderGoodsNum"];
        
        AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
        manager.responseSerializer = [AFJSONResponseSerializer new];
        
        manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html", nil];
        manager.responseSerializer=[AFHTTPResponseSerializer serializer];
        
        [manager POST:@"https://h5pay.jd.com/jdpay/saveOrder" parameters:formDic progress:^(NSProgress * _Nonnull uploadProgress) {
            
            
            
        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
            
            NSString *htmlstring=[[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
            //将第二次请求出来的html字符串加载到webview
            [self.webView loadHTMLString:htmlstring baseURL:[NSURL URLWithString:@"https://h5pay.jd.com/jdpay/saveOrder"]];
            
            NSLog(@"WEB: %@", responseObject);
            
        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
            
        }];
    
    

    相关文章

      网友评论

          本文标题:关于京东支付

          本文链接:https://www.haomeiwen.com/subject/sshimttx.html