Android - Paypal 支付 "sendAuthorizationToServer"

标签 android paypal authorization payment

我正在尝试将 PayPal 集成到我的应用程序中并了解 PayPal SDK 的工作原理我正在使用示例应用程序。我知道在用户按下“购买”按钮后,我需要将授权响应发送到我的服务器以验证付款。问题是我找不到任何关于如何做的例子。我读过 official doc site但我不明白我应该怎么做,因为我发现了非常困惑的信息。

这些是我发现的不同方式:

Verify a mobile payment

curl https://api.sandbox.paypal.com/v1/payments/payment/PAY-5YK922393D847794YKER7MUI 
          -H "Content-Type: application/json" 
          -H "Authorization: Bearer {accessToken}"

Accept a PayPal payment

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

关于Android - Paypal 支付 "sendAuthorizationToServer",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26177219/

相关文章:

android - Flutter AppBar标题与动画进度条重叠

android - 如何清除所有以前的 Activity ~?

android - 蓝牙 LE Gatt 属性 Android

android - Paypal Android SDK 循环支付

java - CLIENT-CERT auth-method 可以与 tomcat 中的 JDBC 域一起使用吗?

java - 两个资源微服务之间的预定通信

security - 在 Google Apps 脚本中管理 API secret 的适当方法是什么?

Android Studio 尝试获取屏幕截图时出错 : "Unexpected error while obtaining screenshot from device: EOF"

paypal - 更正暂停订阅的 paypal IPN 变量

html - Paypal 按钮格式不正确