【发布时间】:2015-06-25 05:00:11
【问题描述】:
我已经解决了一些问题,例如Alipay Integration
但没有人帮助我集成支付宝。谁能告诉我如何在我的 iOS 项目中找出这个集成。
【问题讨论】:
标签: ios objective-c iphone payment-gateway alipay
我已经解决了一些问题,例如Alipay Integration
但没有人帮助我集成支付宝。谁能告诉我如何在我的 iOS 项目中找出这个集成。
【问题讨论】:
标签: ios objective-c iphone payment-gateway alipay
有两种方法可以做到这一点
集成支付宝 SDK 并使用支付宝应用来完成这项工作。 SDK下载地址:https://openhome.alipay.com/doc/docIndex.htm#goto=https://openhome.alipay.com/doc/viewKbDoc.htm?key=236698_261849&type=info
开发 WAP 网络以进行网络支付,这不是我们的工作……
对于演示,您可以在这里查看Alipay SDK
使用支付宝来完成支付功能,我们有以下 步骤: 1)第一次签约和支付宝,获取商家ID (partner) 和 account ID(seller)(这个主要负责 公司) 2) 下载一个公钥和私钥文件(带有 对应的加密和签名) 3)下载SDK(登录付费) 宝:/)它提供了如何非常详细的文件,合同, 如何获取公私钥,如何调用支付 界面。 4) 生成订单信息 5) 拨打支付宝 到客户端,客户端由支付宝支付宝安全服务器处理 6) 支付给商家后的付款退回给客户并 服务器。有一个演示。 SDK集成支付宝功能;这 集成支付功能的具体操作方式,您可以 参考Demo 7) 包括上面demo链接中的alipay sdk。
****include 这是表格视图并选择了行**********
1 // 2 //The selected commodities call to pay treasure quick pay 3 // 4 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 5 { 6 /* 7 *Click the get the prodcut instance and initializes the order information 8 */ 9 Product *product = [_products objectAtIndex:indexPath.row]; 10 11 /* 12 *Parnter and seller only merchant. 13 *The demo parnter and seller information stored in (AlixPayDemo-Info.plist), external merchants can consider stored in *local server or other places. 14 *After signing the contract, pay treasure to be assigned a unique parnter and seller for each merchant. 15 */ 16 //If the partner and seller data stored in other place, please rewrite the following two lines of code 17 NSString *partner = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"Partner"]; 18 NSString *seller = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"Seller"]; 19 20 //Partner and seller failed to get, tips 21 if ([partner length] == 0 || [seller length] == 0) 22 { 23 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Prompt" 24 message:@"The lack of partner or seller. " 25 delegate:self 26 cancelButtonTitle:@"Determine" 27 otherButtonTitles:nil]; 28 [alert show]; 29 [alert release]; 30 return; 31 } 32 33 /* 34 *To generate orders information and signature 35 *Because of the limitation of demo, the private key in the *demo stored in the AlixPayDemo-Info.plist, the external *merchant can *be stored in local server or other places. 36 */ 37 //The commodity information gives the AlixPayOrder member //variable 38 AlixPayOrder *order = [[AlixPayOrder alloc] init]; 39 order.partner = partner; 40 order.seller = seller; 41 order.tradeNO = [self generateTradeNO]; //ID (order shall be formulated by the merchants) 42 order.productName = product.subject; //The title of goods 43 order.productDescription = product.body; //The description of the goods 44 order.amount = [NSString stringWithFormat:@"%.2f",product.price]; //Commodity prices 45 order.notifyURL = @"enter your server url"; //Callback URL 46 47 //Application of registered scheme, defined in the //AlixPayDemo-Info.plist URL types, for quick payment after //successful //re arouse the business application 48 NSString *appScheme = @"AlixPayDemo"; 49 50 //Product information will be spliced into a string 51 NSString *orderSpec = [order description]; 52 NSLog(@"orderSpec = %@",orderSpec); 53 54 //To obtain the private key and the signature of the external //merchant merchant information, according to the situation of //storing private key and the signature, only need to follow //the RSA //signature specification, and the signature string Base64 //coding and //UrlEncode 55 id<DataSigner> signer = CreateRSADataSigner([[NSBundle mainBundle] objectForInfoDictionaryKey:@"RSA private key"]); 56 NSString *signedString = [signer signString:orderSpec]; 57 58 //The sign string formatting string for the order, please follow the format 59 NSString *orderString = nil; 60 if (signedString != nil) { 61 orderString = [NSString stringWithFormat:@"%@&sign=\"%@\"&sign_type=\"%@\"", 62 orderSpec, signedString, @"RSA"]; 63 64 //Fast access to pay a single case and quick call payment interface 65 AlixPay * alixpay = [AlixPay shared]; 66 int ret = [alixpay pay:orderString applicationScheme:appScheme]; 67 68 if (ret == kSPErrorAlipayClientNotInstalled) { 69 UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Prompt" 70 message:@"You did not install Alipay fast payment, please install. " 71 delegate:self 72 cancelButtonTitle:@"Determine" 73 otherButtonTitles:nil]; 74 [alertView setTag:123]; 75 [alertView show]; 76 [alertView release]; 77 } 78 else if (ret == kSPErrorSignError) { 79 NSLog(@"Signature error!"); 80 } 81 82 } 83 84 [tableView deselectRowAtIndexPath:indexPath animated:YES]; 85 }主要集成是以下步骤的关键:
//.Package model order AlixPayOrder *order = [[AlixPayOrder alloc] init]; // To generate orders description NSString *orderSpec = [order description]; //The sign of the 2 id<DataSigner> signer = CreateRSADataSigner(@"The private key key"); // Incoming order description of signature NSString *signedString = [signer signString:orderSpec]; //3 generation order string NSString *orderString = [NSString stringWithFormat:@"%@&sign=\"%@\"&sign_type=\"%@\"", orderSpec, signedString, @"RSA"]; //The 4 call to the payment interface AlixPay * alixpay = [AlixPay shared]; // appScheme: The first merchant own protocol int ret = [alixpay pay:orderString applicationScheme:appScheme];
【讨论】: