views:

1928

answers:

4

Hello I want to use Paypal in my iphone application, I have find the soapRequest to integrating the paypal API. My code is

NSString *soapMessage =  [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" 
"<SOAP-ENV:Envelope xmlns:xsi= \"http://www.w3.org/2001/XMLSchema-instance\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"&gt;\n"
"<SOAP-ENV:Header>\n" 
"<RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\">\n" 
"<Credentials xmlns=\"urn:ebay:apis:eBLBaseComponents\">\n" 
"<Username>api_username</Username>\n" 
"<Password>api_password</Password>\n" 
"<Signature/>\n"     
"<Subject/>\n" 
"</Credentials>\n" 
"</RequesterCredentials>\n" 
"</SOAP-ENV:Header>\n" 
"<SOAP-ENV:Body>\n" 
"<specific_api_name_Req xmlns=\"urn:ebay:api:PayPalAPI\">\n" 
"<specific_api_name_Request>\n" 
"<Version xmlns=urn:ebay:apis:eBLBaseComponents”>service_version</Version>\n" 
"<required_or_optional_fields xsi:type=”some_type_here”>\n"                 
"</required_or_optional_fields>\n" 
"</specific_api_name_Request>\n" 
"</specific_api_name_Req>\n" 
"</SOAP-ENV:Body>\n" 
        "</SOAP-ENV:Envelope>\n"];

NSLog(@"Soap message===%@",soapMessage);


NSString *parameterString = [NSString stringWithFormat:@"USER=%@&PWD=%@&SIGNATURE=%@&VERSION=57.0&METHOD=SetMobileCheckout&AMT=%.2f&CURRENCYCODE=USD&DESC=%@&RETURNURL=%@", userName, password, signature, donationAmount, @"Some Charge", returnCallURL];

NSLog(parameterString);

NSURL *url = [NSURL URLWithString:paypalUrlNVP];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [parameterString length]];

[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [parameterString dataUsingEncoding:NSUTF8StringEncoding]];


NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

if( theConnection ){
    webData = [[NSMutableData data] retain];
// [self displayConnectingView];

}else{
    NSLog(@"theConnection is NULL");
}

But here I am not getting the value of paypalUrlNVP. How can i get it?? And if possible then please give some example of paypalAPI integration in iphone.

I also want to use checkout functionality.I am new in this field so I have no idea about it. So, kindly give me whole sample code. Thanks in advance.

A: 

You appear to be mixing up two different ways of calling the PayPal API. You have a SOAP XML string, which you don't actually use and also then call the NVP (name value pair) API.

You need to decide which you are actually going to use.

The URLs you need to use for the NVP API are:

API Servers for API Signature Security

If you use an API signature, post the request to one ofthese servers:

Sandbox: https://api-3t.sandbox.paypal.com/nvp

Live: https://api-3t.paypal.com/nvp API Servers for API Certificate Security

If you use an API certificate, post the request to oneof these servers:

Sandbox: https://api.sandbox.paypal.com/nvp

Live: https://api.paypal.com/nvp

As described here:

https://cms.paypal.com/us/cgi-bin/?cmd=%5Frender-content&amp;content%5FID=developer/e%5Fhowto%5Fapi%5Fnvp%5FNVPAPIOverview

andynormancx
jaynaiphone
I think you need to enable your PayPal account for Mobile Checkout
andynormancx
ok thanks. I will do it.
jaynaiphone
A: 

Additionally, I think you should URL-encode the name and value parameters that you're passing in.

Ushox
There is no need for that, the NVP values are in the body of the POST request, not in the URL of a GET.
andynormancx
oops! that's correct! Silly me!
Ushox
A: 

@Jaina - Try to follow this link . I believe it would help you.

It's very simple to understand. The link has very simple flow & easy variable names

http://helpmesolve.blogspot.com/

sugar
A: 

You might want to look at this question too (link) which indicates you will have your application rejected by Apple. You need to look at the In App Purchase mechanisms to collect payments in an iPhone App

Kevin