2011-12-10 51 views
-2

如何使用貝寶web服務在iPhone應用程序中集成貝寶。如何使用貝寶web服務在iPhone應用程序中集成貝寶

NSString *parameterString = [NSString stringWithFormat:@"USER=%@&PWD=%@&SIGNATURE=%@&VERSION=57.0&METHOD=SetexpressCheckout&AMT=%.2f&CURRENCYCODE=USD&&DESC=10.00&CancelURL=%@&RETURNURL=%@", userName, password, signature,@"http://www.fourerr.com",returnCallURL]; 
NSURL *url = [NSURL URLWithString:@"https://api-3t.sandbox.paypal.com/nvp"]; 
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]; 
[theConnection start]; 

控制檯:

getting error: paypal Data: TIMESTAMP=2011%2d12%2d10T11%3a43%3a53Z&CORRELATIONID=2e0852675ece5&ACK=Failure&VERSION=57%2e0&BUILD=2271164&L_ERRORCODE0=10401&L_ERRORCODE1=10471&L_ERRORCODE2=10472&L_SHORTMESSAGE0=Transaction%20refused%20because%20of%20an%20invalid%20argument%2e%20See%20additional%20error%20messages%20for%20details%2e&L_SHORTMESSAGE1=Transaction%20refused%20because%20of%20an%20invalid%20argument%2e%20See%20additional%20error%20messages%20for%20details%2e&L_SHORTMESSAGE2=Transaction%20refused%20because%20of%20an%20invalid%20argument%2e%20See%20additional%20error%20messages%20for%20details%2e&L_LONGMESSAGE0=Order%20total%20is%20invalid%2e&L_LONGMESSAGE1=ReturnURL%20is%20invalid%2e&L_LONGMESSAGE2=CancelURL%20is%20invalid%2e&L_SEVERITYCODE0=Error&L_SEVERITYCODE1=Error&L_SEVERITYCODE2=Error 

回答

1

錯誤消息說Order total is invalid,我沒有看到你的參數字符串訂單總數。也許這是問題?

+0

請爲我提供適當的PayPal webservice的URLstring。 – saurav

+1

請閱讀API文檔。 https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/howto_api_reference – tobiasbayer