I have gone through some questions like Alipay Integration
but none did help me to integrate alipay .Can anyone plz tell how to figure out this Integration in my iOS project.
I have gone through some questions like Alipay Integration
but none did help me to integrate alipay .Can anyone plz tell how to figure out this Integration in my iOS project.
there are two ways to do this
Integrate the Alipay SDK and use Alipay app to do the job. SDK download from: https://openhome.alipay.com/doc/docIndex.htm#goto=https://openhome.alipay.com/doc/viewKbDoc.htm?key=236698_261849&type=info
Develop a WAP web to pay on web, this is not our job…
also for demo you can look here Alipay SDK
Use Alipay to a complete payment function, we have the following steps: 1) The first contract and pay treasure, obtain business ID (partner) and account ID(seller) (this is mainly in charge of the company) 2) Download a public and private key file (with the corresponding encryption and signature) 3) Download SDK (login pay treasure: /) It provides how to a very detailed document, contract, how to obtain a public and private key, how to call the payment interface. 4) To generate orders information 5) Call to pay treasure to the client, the client by Alipay Alipay secure server dealing 6) Payment after payment to the merchant returned to the client and server.There is a Demo. integrated Alipay function of SDK; the specific mode of operation of integrated payment function, you can refer to the Demo 7) include alipay sdk from above demo link.
****include this is table view did select row**********
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 }
The main integration is the key to the following steps:
//.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];