Android - PayPal 支付“sendAuthorizationToServer”

Posted

技术标签:

【中文标题】Android - PayPal 支付“sendAuthorizationToServer”【英文标题】:Android - PayPal payment "sendAuthorizationToServer" 【发布时间】:2014-11-28 09:50:25 【问题描述】:

我正在尝试将 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 这样的库,而且我以前从未需要任何类型的网络服务。

感谢您的帮助。

【问题讨论】:

嗨,您解决了这个问题并找到了解决方案吗? 【参考方案1】:

@jgarciabt - 您想要验证在您的移动应用中创建的付款。这是一个示例实现:https://github.com/avidas/rest-api-sdk-python/tree/master/samples/mobile_backend

【讨论】:

我以前读过,但我以前从未使用过python,我不知道我是否可以以及如何将这段代码集成到android上。 支付验证的一个要点是从您的服务器而不是从移动设备执行。

以上是关于Android - PayPal 支付“sendAuthorizationToServer”的主要内容,如果未能解决你的问题,请参考以下文章

Android 是不是支持通过 PayPal 进行应用内支付模式? [复制]

沙盒测试模式下 Android 中的 Paypal 支付网关集成问题

Android - PayPal 支付“sendAuthorizationToServer”

使用 Braintree SDK 在 Android 中支付 PayPal

协助 PayPal 自适应支付 - IOS 和 Android 开发

Android PayPal 支付集成