支付宝iOS SDK的那些坑(系统繁忙,请稍后再试)

问题

官方示例中支付相关的代码


//构造订单

NSString*appScheme =@"AlipaySdkDemo";NSString* orderInfo = [selfgetOrderInfo:indexPath.row];

NSString* signedStr = [selfdoRsa:orderInfo];//形成订单参数

NSString*orderString = [NSStringstringWithFormat:@"%@&sign=\"%@\"&sign_type=\"%@\"",orderInfo, signedStr,@"RSA"];//调用支付借口

[AlixLibService payOrder:orderString AndScheme:appScheme seletor:_result target:self];

问题就出在orderInfo这里 那么orderInfo是什么呢 ?


-(NSString*)getOrderInfo:(NSInteger)index{

/**点击获取prodcut实例并初始化订单信息*/

Product*product= [_products objectAtIndex:index];

AlixPayOrder*order= [[AlixPayOrder alloc] init];

order.partner= PartnerID;

order.seller= SellerID;

order.tradeNO= [selfgenerateTradeNO];//订单ID(由商家自行制定)

order.productName= product.subject;//商品标题

order.productDescription= product.body;//商品描述

order.amount= [NSStringstringWithFormat:@"%.2f",product.price];//商品价格order.notifyURL=@"http%3A%2F%2Fwwww.xxx.com";//回调URL

return[order description];

}

可以到看orderInfo就是AlixPayOrder的字符串化 再看看其description函数

-(NSString *)description{

NSMutableString* discription = [NSMutableStringstring];

[discription appendFormat:@"partner=\"%@\"",self.partner?self.partner:@""];

[discription appendFormat:@"&seller_id=\"%@\"",self.seller?self.seller:@""];

[discription appendFormat:@"&out_trade_no=\"%@\"",self.tradeNO?self.tradeNO:@""];

[discription appendFormat:@"&subject=\"%@\"",self.productName?self.productName:@""];

[discription appendFormat:@"&body=\"%@\"",self.productDescription?self.productDescription:@""];

[discription appendFormat:@"&total_fee=\"%@\"",self.amount?self.amount:@""];

[discription appendFormat:@"¬ify_url=\"%@\"",self.notifyURL?self.notifyURL:@""];

[discription appendFormat:@"&service=\"%@\"",self.serviceName?self.serviceName:@"mobile.securitypay.pay"];

[discription appendFormat:@"&_input_charset=\"%@\"",self.inputCharset?self.inputCharset:@"utf-8"];

[discription appendFormat:@"&payment_type=\"%@\"",self.paymentType?self.paymentType:@"1"];//下面的这些参数,如果没有必要(value为空),则无需添加

[discription appendFormat:@"&return_url=\"%@\"",self.returnUrl?self.returnUrl:@"www.xxx.com"];

[discription appendFormat:@"⁢_b_pay=\"%@\"",self.itBPay?self.itBPay:@"1d"];

[discription appendFormat:@"&show_url=\"%@\"",self.showUrl?self.showUrl:@"www.xxx.com"];

for(NSString* keyin[self.extraParamsallKeys]){[discription appendFormat:@"&%@=\"%@\"", key, [self.extraParamsobjectForKey:key]];}

returndiscription;

}

你可能感兴趣的:(支付宝iOS SDK的那些坑(系统繁忙,请稍后再试))