在 Android 中使用 Pay-key 来自 PayPal 的交易详细信息
我正在将 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请求付款详细信息的正确方法是 :
,设置正文内容使用 :
,然后正常执行。
The correct way to request payment details is :
and to set body content use :
and then execute normally.