在 Android 中使用 Pay-key 来自 PayPal 的交易详细信息

发布于 2024-12-25 20:41:52 字数 3436 浏览 2 评论 0原文

我正在将 paypal 集成到我的应用程序中,一切正常。现在我想在我的 android 中获取 paypal 的所有交易详细信息,因此使用 paykey 我尝试编写代码。

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 获取交易详细信息。

I am integrating paypal in my application and everything is working fine.Now i wanted to have all transaction details from paypal in my android and so using paykey i tried to write a code..My code for obtaining transaction detail is as follow:

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();

        }

and i am getting following response from them

<?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>

Can any one help me why i am getting this error or can any give me some example how can i get transaction details from paypal.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北方。的韩爷 2025-01-01 20:41:52

请求付款详细信息的正确方法是 :

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"));

,然后正常执行。

The correct way to request payment details is :

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");

and to set body content use :

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

and then execute normally.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文