zoukankan      html  css  js  c++  java
  • Announcing Mobile SDK V2.0

    As you might have read over at our PayPal Forward Blog it’s time to celebrate for PayPal | Developer. One year ago we relaunched our Developer Platform with way clearer documentation, new REST APIs and our CardIO-enhanced Mobile SDK that allows for frictionless payments on Android and iOS.

    Today I want to quickly elaborate on an amazing new feature of our mSDK version 2.0 called Future Payments that allows for great use-cases like subscription payments without requiring the user to re-authorize each payment by logging in again. Great experiences like the ones that you can find when using Uber can be created by using this kind of payment. By authorizing the application once to handle future transaction the user grants the application a revokable token that will be passed in all future transactions and therefore skips the login step.

    Implementing this step is actually very easy as our SDK got even easier with version 2. First of all we need to change the configuration of the SDK slightly. In the following examples I will showcase how to do so when working on Android apps – bear in mind that implementing this feature in iOS is equally easy to handle:

      private static PayPalConfiguration config = new PayPalConfiguration()
      .environment(CONFIG_ENVIRONMENT)
      .clientId(CONFIG_CLIENT_ID)
      // The following are only used in PayPalFuturePaymentActivity.
      .merchantName("Innovative cab app")
      .merchantPrivacyPolicyUri(Uri.parse("https://www.example.com/privacy"))
      .merchantUserAgreementUri(Uri.parse("https://www.example.com/legal"));

    If you’ve worked with our SDK prior this version you will see that the configuration got much easier by removing all Intent Extras and adding dedicated methods for initializing the SDK.

    After the user logged in an OAuth 2.0 authorize token is being returned which can be exchanged against a short-lived access token. Furthermore a refresh token is being returned which we will need to acquire a new access token once the previous one becomes invalid.

      Intent intent = new Intent(MyActivity.this, PayPalFuturePaymentActivity.class);
      startActivityForResult(intent, REQUEST_CODE_FUTURE_PAYMENT);
    view rawintent.java hosted with ❤ by GitHub

    By using the startActivityForResult mechanism we receive the PayPalAuthorization in onActivityForResult:

      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if (requestCode == REQUEST_CODE_FUTURE_PAYMENT) {
      if (resultCode == Activity.RESULT_OK) {
      PayPalAuthorization auth = data
      .getParcelableExtra(PayPalFuturePaymentActivity.EXTRA_RESULT_AUTHORIZATION);
      if (auth != null) {
      String authorization_code = auth.getAuthorizationCode();
      // send authorization code to server to receive the access & refresh code
      }
      }
      }
      }

    The payment is being handled on server-side – to do so we hand over the app’s correlation ID and payment details to the backend. To acquire the correlation ID we leverage a method that we introduced with version 2.0 of the SDK:

      String correlationId = PayPalConfiguration.getApplicationCorrelationId(this);

    It is required that the application provides a way to revoke the token on client-side to ensure a user-friendly experience.

    We are looking forward to bringing even more great features to the SDK and are as always keen for your feedback!

    Best regards,
    Tim

  • 相关阅读:
    关于 锁的四种状态与锁升级过程 图文详解
    悲观锁与乐观锁的实现(详情图解)
    面试三轮我倒在了一道sql题上——sql性能优化
    我的程序跑了60多小时,就是为了让你看一眼JDK的BUG导致的内存泄漏。
    快来!我从源码中学习到了一招Dubbo的骚操作!
    我从LongAdder中窥探到了高并发的秘籍,上面只写了两个字...
    震惊!ConcurrentHashMap里面也有死循环,作者留下的“彩蛋”了解一下?
    mybatis 逆向工程使用姿势不对,把表清空了,心里慌的一比,于是写了个插件。
    吐血输出:2万字长文带你细细盘点五种负载均衡策略。
    mybatis开发,你用 xml 还是注解?我 pick ...
  • 原文地址:https://www.cnblogs.com/android-blogs/p/6409212.html
Copyright © 2011-2022 走看看