How to implement paypal payment integration in iphone?
I have created one application in iphone sdk. i have already taken user credit card details like ccnumber,ccverification number etc.. now i have task to implement pay button on this user clicks the button payment should be done. user must not have to enter its credit-card no or other details because as i have taken already.so user interaction should not be done.
I have used this method
-(IBAction)pay:(id)sender
{
// perfomingSetMobileCheckout=YES;
// recordResults = FALSE;
NSString *parameterString = [NSString stringWithFormat:@"USER=myuser"
"&PWD=mypassword"
"&SIGNATURE=mysignature"
"&METHOD=DoDirectPayment"
"&CREDITCARDTYPE=Visa"
"&ACCT=1234"
"&EXPDATE=sep/11"
"&CVV2=256"
"&AMT=6549"
"&FIRSTNAME=Demo"
"&LASTNAME=Test"
"&STREET=WallStreet"
"&CITY=HI"
"&STATE=Ohio"
"&COUNTRY=US"
"&ZIP=98251"
"&COUNTRYCODE=US"
"&PAYMENTACTION=Sale"
"&VERSION=2.3"];
// txtCreditCardType.text,txtAccountNumber.text,txtExpireDate.text,txtTotalAmount.text,txtFirstName.text,txtLastName.text,txtStreet.text,txtCity.text,txtState.text,txtCountry.text,txtZip.text];
NSLog(@"parameter:%@",parameterString)开发者_开发知识库;
NSString *str = [NSString stringWithFormat:@"https://api-3t.sandbox.paypal.com/nvp?%@",parameterString];
NSLog(@"str:=%@",str);
NSURL *url = [NSURL URLWithString:@"https://api-3t.sandbox.paypal.com/nvp"];
//https://www.sandbox.paypal.com/cgi-bin/webscr
//https://api-3t.sandbox.paypal.com/nvp;
NSLog(@"url:%@",url);
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [parameterString length]];
NSLog(@"msgLength:%@",msgLength);
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [parameterString dataUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"theRequest:%@",theRequest);
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
NSLog(@"Connection:%@",theConnection);
if( theConnection )
{
NSMutableData *webData = [[NSMutableData data] retain];
NSLog(@"Data:=%@",webData);
//[self displayConnectingView];
}else
{
NSLog(@"theConnection is NULL");
}
}
So when user tap the pay button payment should be done by paypal & user only get the message that payment done or not.
how to implement that payment button?
Try using the PayPal payment library for iOS. It does everything for you!
PayPal library
精彩评论