从使用贝宝支付键的机器人交易细节 [英] Transaction details from paypal using Pay-key in android

查看:170
本文介绍了从使用贝宝支付键的机器人交易细节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序集成PayPal和一切工作fine.Now我想在我的Andr​​oid等使用paykey来自贝宝的所有交易细节我试着写一个code..My $ C $下获得交易明细情况如下:

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>

任何一个可以帮助我,为什么我收到此错误,或者可以在任何给我一些例子,我怎么能得到来自PayPal的交易细节。

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.

推荐答案

要求付款明细正确的方法是:

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.

这篇关于从使用贝宝支付键的机器人交易细节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆