在iPhone应用程序中使用PayPal API [英] Using the PayPal API in an iPhone application

查看:213
本文介绍了在iPhone应用程序中使用PayPal API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想在我的iphone应用程序中使用Paypal,我发现soapRequest集成了paypal API。我的代码是

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/\">\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");
}

但在这里我没有得到paypalUrlNVP的价值。我怎么才能得到它??
如果可能的话请在iphone中给出一些paypalAPI集成的例子。

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.

推荐答案

您似乎混淆了调用PayPal API的两种不同方式。你有一个SOAP XML字符串,你实际上并没有使用它,然后调用NVP(名称值对)API。

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.

您需要为NVP API使用的网址是:

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


用于API签名安全性的API服务器

API Servers for API Signature Security

如果您使用API​​签名,请将
请求发布到其中一个服务器:

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

沙箱:
https:// api-3t。 sandbox.paypal.com/nvp

直播: https://api-3t.paypal.com/nvp
API证书的API服务器
安全性

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

如果您使用API​​证书,请向这些服务器中的一个发布
请求:

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

沙盒:
https://api.sandbox.paypal.com / nvp

直播: https:/ /api.paypal.com/nvp

如下所述:

https:// cms .paypal.com / us / cgi-bin /?cmd = _render-content& content_ID = developer / e_howto_api_nvp_NVPAPIOverview

这篇关于在iPhone应用程序中使用PayPal API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆