简体   繁体   English

Android-PayPal付款“ sendAuthorizationToServer”

[英]Android - PayPal payment “sendAuthorizationToServer”

I'm trying to integrate PayPal on my app and to learn how PayPal SDK works I'm playing with the sample app. 我正在尝试将PayPal集成到我的应用程序中,并了解PayPal SDK的工作方式。 I know that after the user press "buy" button I need to send the authorization response to my server to verify the payment. 我知道在用户按下“购买”按钮后,我需要将授权响应发送到我的服务器以验证付款。 The problem is that I couldn't find any example about how to do it. 问题是我找不到有关如何执行此操作的任何示例。 I've read the official doc site but I don't understand how should I do it because I found very confuse information. 我已经阅读了官方文档站点,但是由于发现非常混乱的信息,所以我不知道该怎么做。

These are the different ways that I found: 这些是我发现的不同方式:

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" }'

Which is the correct way to do it and what are the differences between both? 正确的方法是什么?两者之间有什么区别?

This is my real problem. 这是我真正的问题。 The sample app has this fragment of code, where get the response from PayPal's servers, but I don't know how integrate the code above with the Java code. 示例应用程序具有这段代码,可以从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);
     }
 }

I have some experience with Android but this is the first time that I try to integrate one library like PayPal and I've never needed any kind of web service before. 我对Android有一定的经验,但这是我第一次尝试集成PayPal之类的库,而且以前从未需要任何类型的Web服务。

Thank you for your help. 谢谢您的帮助。

@jgarciabt - You want to verify the payment that was created in your mobile app. @jgarciabt-您要验证在移动应用程序中创建的付款。 Here is an example implementation: https://github.com/avidas/rest-api-sdk-python/tree/master/samples/mobile_backend 这是一个示例实现: https : //github.com/avidas/rest-api-sdk-python/tree/master/samples/mobile_backend

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM