1,在新的方法调用支付宝支付成功后,支付宝会返回几个参数,其中一个比较长的字符串里面会用需要用到的字段,如下
result="partner=\"1234\"&seller_id=\"123@gmail.com\"&out_trade_no=\"S1234\"&subject=\"\U522b\U5885\U8ba2\U5355\"&body=\"\U5885\"&total_fee=\"0.1\"¬ify_url=\"http://baidu.com\"&service=\"mobile.secy.pay\"&payment_type=\"1\"&_input_charset=\"UTF-8\"&it_b_pay=\"30m\"&success=\"true\"&sign_type=\"RSA\"&sign=\"dMiqkRZvnpTnJp9zbwGNAL3Bu43RMocNwOAsRYFnueZX8Uwy81zXHLg=\"";
下面是解析的方法:
NSString *string = result[@"result"];
NSArray *array = [string componentsSeparatedByString:@"&"];
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
for (NSString *str in array) {
NSArray *array =[str componentsSeparatedByString:@"="];
dict[array.firstObject] = array.lastObject;
}
NSLog(@"%@",dict);
NSString *trade = dict[@"out_trade_no"];
NSLog(@"-------==== %@",trade);