android app取得paypal PaymentDetails
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");
httppost.setHeader("X-PAYPAL-SECURITY-USERID","username");//
httppost.setHeader("X-PAYPAL-SECURITY-PASSWORD","passowrd");//
httppost.setHeader("X-PAYPAL-SECURITY-SIGNATURE","signature");//
httppost.setHeader("X-PAYPAL-APPLICATION-ID","APP-80W284485P519543T");// app id, app id
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", transID));
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];
StringBuffer buffer = new StringBuffer();
int len = 0;
while (-1 != (len = is.read(data1))) {
buffer.append(new String(data1, 0, len));
}
System.out.println("--------->" + buffer.toString());
is.close();
} catch (Exception e) {
Log.e("", "error " + e);
}
以上のユーザー、パスワード、証明書を自分の情報に置き換えなければなりません.
以上のシステムout.println("--------->"+ buffer.toString());Paypalの支払いが成功した後に返される詳細で、取引idを含む.しかし、セキュリティ上の考慮から、クライアントでこのステップを実行することは推奨されません.このステップを実行するには、クライアントプログラムにpaypal証明書などの一連の情報が必要です.証明書をコードに書き込むと、一定のリスクがあります.これもPaypalが推奨しない理由です(paykeyがあれば、詳細なアドレスなど、より多くの情報を得ることができます).