2012-01-09 121 views
2

我在我的應用程序中集成貝寶,一切工作正常。現在我想從我的android的貝寶所有交易細節,所以使用paykey我試圖寫一個代碼。獲得交易明細。我的代碼如下:交易詳情從貝寶使用付款鍵在Android

if(resultTitle == "SUCCESS") 
     { 
      try{ 


       HttpClient httpclient = new DefaultHttpClient(); 
       HttpPost httppost = null; 
       httppost = new HttpPost("https://svcs.sandbox.paypal.com/AdaptivePayments/PaymentDetails"); 
       httppost.setHeader("Content-Type", "application/x-www-form-urlencoded"); 


        // Add your data 
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); 
        nameValuePairs.add(new BasicNameValuePair("X-PAYPAL-SECURITY-USERID", "parth_1325956186_biz_api1.bcod.co.in")); 
        nameValuePairs.add(new BasicNameValuePair("X-PAYPAL-SECURITY-PASSWORD", "334367211")); 
        nameValuePairs.add(new BasicNameValuePair("X-PAYPAL-SECURITY-SIGNATURE", "An5ns1Kso7MUDHR4ErQKJJJ4qi4-AI0T5BBCHc3gWzBV9Q81jcP6LFD6")); 
        nameValuePairs.add(new BasicNameValuePair("X-PAYPAL-APPLICATION-ID", "APP-80W284485P519543T")); 
        nameValuePairs.add(new BasicNameValuePair("X-PAYPAL-REQUEST-DATA-FORMAT", "nv")); 
        nameValuePairs.add(new BasicNameValuePair("X-PAYPAL-RESPONSE-DATA-FORMAT", "nv")); 
        nameValuePairs.add(new BasicNameValuePair("payKey", resultExtra)); 
        nameValuePairs.add(new BasicNameValuePair("requestEnvelope.errorLanguage", "en_US")); 
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 
       HttpResponse response = httpclient.execute(httppost); 
       HttpEntity entity = response.getEntity(); 
       InputStream is = entity.getContent(); 
       byte[] data1; 
       data1 = new byte[256]; 
       buffer = new StringBuffer(); 
       int len = 0; 
       while (-1 != (len = is.read(data1))) 
        { 
        buffer.append(new String(data1, 0, len)); 
        } 
       Log.e("log_tag",""+buffer.toString()); 

       //Make the comparison case-insensitive. 
       is.close(); 
       }catch(Exception e) 
       { 
        Log.e("","error "+ e); 
       } 
       Log.e("","resultExtra "+ resultExtra); 
       Intent go = new Intent(getBaseContext(),membership_pack_clear.class); 
       startActivity(go); 

       finish(); 

     } 

,我正從他們

<?xml version='1.0' encoding='UTF-8'?> 
<ns3:FaultMessage xmlns:ns3="http://svcs.paypal.com/types/common" xmlns:ns2="http://svcs.paypal.com/types/ap"> 
<responseEnvelope><timestamp>2012-01-09T05:16:35.886-08:00</timestamp> 
<ack>Failure</ack> 
<correlationId>aa06daf9a0985</correlationId> 
<build>2279004</build> 
</responseEnvelope><error><errorId>520003</errorId> 

<domain>PLATFORM</domain> 
<subdomain>Application</subdomain> 
<severity>Error</severity> 
<category>Application</category> 
<message>Authentication failed. API credentials are incorrect.</message> 

</error></ns3:FaultMessage> 

以下響應任何一個可以幫助我,爲什麼我收到此錯誤或任何可以給我一些示例如何從paypal獲取交易詳情。

+0

我面臨同樣的問題,並在每一個PayPal網站和文檔編寫,讓你可以實現像 1-即時付款通知的功能數量paykey後 2 - 貝寶交易明細 3-退款 但怎麼樣? 請建議如何通過paykey獲取交易詳情。 – 2015-11-17 07:31:02

回答

2

要求付款細節正確的方法是:

httppost.setHeader("X-PAYPAL-SECURITY-USERID", "parth_1325956186_biz_api1.bcod.co.in"); 
httppost.setHeader("X-PAYPAL-SECURITY-PASSWORD", "334367211"); 
httppost.setHeader("X-PAYPAL-SECURITY-SIGNATURE", "An5ns1Kso7MUDHR4ErQKJJJ4qi4-AI0T5BBCHc3gWzBV9Q81jcP6LFD6"); 
httppost.setHeader("X-PAYPAL-APPLICATION-ID", "APP-80W284485P519543T"); 
httppost.setHeader("X-PAYPAL-REQUEST-DATA-FORMAT", "NV"); 
httppost.setHeader("X-PAYPAL-RESPONSE-DATA-FORMAT", "NV"); 

,並設置正文內容使用:

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); 
nameValuePairs.add(new BasicNameValuePair("payKey", "AP-4DJ54615WA356150J")); 
nameValuePairs.add(new BasicNameValuePair("requestEnvelope.errorLanguage", "en_US")); 

,然後執行正常。