我正在尝试在我的应用程序上集成PayPal,为了了解PayPal SDK的工作原理,我正在使用示例应用程序。我知道在用户按下"购买"按钮后,我需要将授权响应发送到我的服务器以验证付款。问题是我找不到任何关于如何做到这一点的例子。我读过官方的文档网站,但我不明白我应该怎么做,因为我发现信息非常混乱。
这些是我发现的不同方式:
验证移动支付
curl https://api.sandbox.paypal.com/v1/payments/payment/PAY-5YK922393D847794YKER7MUI
-H "Content-Type: application/json"
-H "Authorization: Bearer {accessToken}"
接受PayPal支付
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这样的库,我以前从未需要过任何类型的网络服务。
谢谢你的帮助。
@jgarciabt-您想要验证在移动应用程序中创建的付款。以下是一个示例实现:https://github.com/avidas/rest-api-sdk-python/tree/master/samples/mobile_backend