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

Announcing Mobile SDK V2.0的更多相关文章

  1. 原因是未找到“sgen.exe”,或未安装 .NET Framework SDK v2.0

    visual studio编译出现错误:错误 2 任务失败,原因是未找到“sgen.exe”,或未安装 .NET Framework SDK v2.0.该任务正在注册表项 HKEY_LOCAL_MAC ...

  2. Deepin15.8系统下安装QorIQ Linux SDK v2.0 yocto成功完美运行的随笔

    2019.2.17日:最终安装成功,完美解决! 2019.2.16日:最终安装未成功,但是过程中排除 了几个bug,前进了几步,仅供参考. 写在最前面,yocto安装是有系统要求的,Deepin 15 ...

  3. Kinect for Windows SDK v2.0 开发笔记 (十五) 手势帧

     (转载请注明出处) 使用SDK: Kinect for Windows SDK v2.0 public preview1409 同前面,由于SDK未完毕,不附上函数/方法/接口的超链接. 这次最 ...

  4. Gprinter Android SDK V2.0 使用说明

    佳博特约经销商,此店购买的打印机问题优先解决哟 https://shop107172033.taobao.com/index.htm?spm=2013.1.w5002-9520741823.2.V1p ...

  5. Hi3531 SDK v2.0.8.0 安装

    1.Hi3531 SDK包位置 在"Hi3531_V100R001***/01.software/board"目录下,您可以看到一个 Hi3531_SDK_Vx.x.x.x.tgz ...

  6. ".NET Compact Framework v2.0 could not be found."

    参考: http://blog.csdn.net/godcyx/article/details/7348431 问题原因: That's a known issue where VS can't di ...

  7. 编译器错误消息: CS0016: 未能写入输出文件“c:/Windows/Microsoft.NET/Framework/v2.0.50727/....dll”--“拒绝访问。

    错误如下: “/”应用程序中的服务器错误. 编译错误 说明: 在编译向该请求提供服务所需资源的过程中出现错误.请检查下列特定错误详细信息并适当地修改源代码. 编译器错误消息: CS0016: 未能写入 ...

  8. ArcGIS Runtime for Android开发教程V2.0(4)基础篇---MapView

    原文地址: ArcGIS Runtime for Android开发教程V2.0(4)基础篇---MapView - ArcGIS_Mobile的专栏 - 博客频道 - CSDN.NET http:/ ...

  9. ArcGIS Runtime for Android开发教程V2.0(2)开发环境配置

    原文地址: ArcGIS Runtime for Android开发教程V2.0(2)开发环境配置 - ArcGIS_Mobile的专栏 - 博客频道 - CSDN.NET http://blog.c ...

随机推荐

  1. Zookeeper介绍及安装部署

    本节内容: Zookeeper介绍 Zookeeper特点 Zookeeper应用场景 用到了Zookeeper的一些系统 Zookeeper集群安装部署 一.Zookeeper介绍 是一个针对大型分 ...

  2. JS几种变量交换方式以及性能分析对比

    前言 "两个变量之间的值得交换",这是一个经典的话题,现在也有了很多的成熟解决方案,本文主要是列举几种常用的方案,进行大量计算并分析对比. 起由 最近做某个项目时,其中有一个需求是 ...

  3. JavaScript中正则的使用(1)

    通过例子学习正则中的常见语法(1) $num javascript var a = 'javascript'; var b = a.replace(/(java)(script)/gi, '$2-$1 ...

  4. vscode 配置import @ 路径提示及代码智提

    1.安装插件:Path Intellisense 2.配置: "path-intellisense.mappings": { "@": "${work ...

  5. 基于 Laravel 开发博客应用系列 —— Homestead 和 Laravel 安装器

    1.Homestead 从主机操作系统的控制台中(Windows 中被称作命令提示符,Linux 中被称作终端),你可以轻松通过不带参数的homestead 命令查看所有有效的 Homestead 命 ...

  6. 基于 Laravel 开发博客应用系列 —— 设置 Windows 本地开发环境

    1.安装原生PHP 下载/解压 PHP 到 PHP 下载页下载最新版本的 PHP(如果使用 Laravel 5.1 的话需要 PHP 5.5.9+ 版本),解压下载的zip格式压缩文件到本地目录,比如 ...

  7. 2017-2018-1 20179202《Linux内核原理与分析》第十一周作业

    Metasploit实现木马生成.捆绑.免杀 1.预备知识 (1)Metasploit Metasploit是一款开源的安全漏洞检测工具,全称叫做The Metasploit Framework,简称 ...

  8. JAVA基础知识之jdk下载与安装

    一.下载JDK 下载网址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 如果 ...

  9. 【原创】MySQL常用脚本整理

    #1.查看表容量空间 ) ) ) AS 'free_size(G)' FROM information_schema.tables WHERE TABLE_SCHEMA='test' AND TABL ...

  10. 移动端h5下ul实现横向滚动css代码

    html代码: <ul id="category"> <li>品牌团</li> <li>美体个护</li> <li ...