gpt4 book ai didi

iphone - 在 iPhone 应用程序中使用 PayPal API

转载 作者:太空宇宙 更新时间:2023-11-03 16:04:28 24 4
gpt4 key购买 nike

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

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 的示例。

我也想使用结帐功能。我是这个领域的新手,所以我对此一无所知。所以,请给我完整的示例代码。提前致谢。

最佳答案

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

您需要决定您实际要使用哪个。

您需要用于 NVP API 的 URL 是:

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

如这里所述:

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

关于iphone - 在 iPhone 应用程序中使用 PayPal API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1366864/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com