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

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

问题描述

您好,我想在我的 iphone 应用程序中使用 Paypal,我找到了集成 Paypal API 的soapRequest.我的代码是

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"?>
" 
"<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/">
"
"<SOAP-ENV:Header>
" 
"<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI">
" 
"<Credentials xmlns="urn:ebay:apis:eBLBaseComponents">
" 
"<Username>api_username</Username>
" 
"<Password>api_password</Password>
" 
"<Signature/>
"     
"<Subject/>
" 
"</Credentials>
" 
"</RequesterCredentials>
" 
"</SOAP-ENV:Header>
" 
"<SOAP-ENV:Body>
" 
"<specific_api_name_Req xmlns="urn:ebay:api:PayPalAPI">
" 
"<specific_api_name_Request>
" 
"<Version xmlns=urn:ebay:apis:eBLBaseComponents">service_version</Version>
" 
"<required_or_optional_fields xsi:type="some_type_here">
"                 
"</required_or_optional_fields>
" 
"</specific_api_name_Request>
" 
"</specific_api_name_Req>
" 
"</SOAP-ENV:Body>
" 
                          "</SOAP-ENV:Envelope>
"];

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 的 URL 是:

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/nvpAPI 证书的 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天全站免登陆