我正在嘗試在我的應用中整合PayPal並學習PayPal SDK的工作方式我正在玩示例應用。我知道在用戶按「購買」按鈕後,我需要將授權響應發送到我的服務器以驗證付款。問題是,我找不到有關如何操作的示例。我已閱讀official doc site,但我不明白該怎麼做,因爲我發現了非常混淆的信息。Android - PayPal支付「sendAuthorizationToServer」
這些是我找到了不同的方式:
curl https://api.sandbox.paypal.com/v1/payments/payment/PAY-5YK922393D847794YKER7MUI
-H "Content-Type: application/json"
-H "Authorization: Bearer {accessToken}"
curl -v https://api.sandbox.paypal.com/v1/payments/payment/PAY-6RV70583SB702805EKEYSZ6Y/execute/
-H 'Content-Type: application/json'
-H 'Authorization: Bearer {accessToken}'
-d '{ "payer_id" : "7E7MGXCWTTKK2" }'
這是做什麼都之間的差異的正確方法是什麼?
這是我真正的問題。示例應用程序具有這段代碼,從PayPal的服務器獲取響應,但我不知道如何將上面的代碼與Java代碼集成。
PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
if (confirm != null) {
try {
Toast.makeText(this,"Paymnet Successful",Toast.LENGTH_LONG).show();
Log.i(TAG, confirm.toJSONObject().toString(4));
Log.i(TAG, confirm.getPayment().toJSONObject().toString(4));
/**
* TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification
* or consent completion.
* See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
* for more details.
*
* For sample mobile backend interactions, see
* https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend
*/
Toast.makeText(
getApplicationContext(),
"PaymentConfirmation info received from PayPal", Toast.LENGTH_LONG)
.show();
} catch (JSONException e) {
Log.e(TAG, "an extremely unlikely failure occurred: ", e);
}
}
我有Android的一些經驗,但是這是我第一次嘗試一個庫如PayPal整合,我從來沒有需要任何形式的網絡服務之前。
謝謝你的幫助。
嗨,你是否克服了這個問題,並找到了解決方案? – securecurve 2015-11-28 16:25:18