标签:
1.封装订单模型
AlixPayOrder *order = [[AlixPayOrder alloc] init];
// 生成订单描述
NSString *orderSpec = [order description];
2.签名
id<DataSigner> signer = CreateRSADataSigner(@“私钥key”);
// 传入订单描述 进行 签名
NSString *signedString = [signer signString:orderSpec];
3.生成订单字符串
NSString *orderString = [NSString stringWithFormat:@"%@&sign=\"%@\"&sign_type=\"%@\"",
orderSpec, signedString, @"RSA"];
4.调用支付接口
AlixPay * alixpay = [AlixPay shared];
// appScheme:商户自己的协议头
int ret = [alixpay pay:orderString applicationScheme:appScheme];
1 - (IBAction)buy { 2 // 1.生成订单信息 3 AlixPayOrder *order = [[AlixPayOrder alloc] init]; 4 order.partner = PartnerID; // 商户ID 5 order.seller = SellerID; // 帐号ID 6 7 order.tradeNO = @"2014082717183778587475"; // 订单ID(由商家自行制定) 8 order.productName = self.deal.title; // 商品标题 9 order.productDescription = self.deal.desc; // 商品描述 10 order.amount = [NSString stringWithFormat:@"%.2f", [self.deal.current_price floatValue]]; //商品价格 11 order.notifyURL = @"http%3A%2F%2Fwwww.xxx.com"; // 回调URL 12 13 // 2.签名加密 14 id<DataSigner> signer = CreateRSADataSigner(PartnerPrivKey); 15 NSString *signedString = [signer signString:[order description]]; 16 17 // 3.利用订单信息、签名信息、签名类型生成一个订单字符串 18 NSString *orderString = [NSString stringWithFormat:@"%@&sign=\"%@\"&sign_type=\"%@\"", 19 [order description], signedString, @"RSA"]; 20 21 // 4.打开支付宝,传递订单信息 22 [AlixLibService payOrder:orderString AndScheme:@"heituan" seletor:@selector(paymentResultDelegate:) target:self]; 23 }
标签:
原文地址:http://www.cnblogs.com/oc-bowen/p/5341536.html