博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Announcing Mobile SDK V2.0
阅读量:6425 次
发布时间:2019-06-23

本文共 3277 字,大约阅读时间需要 10 分钟。

As you might have read over  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"));
 hosted with 
❤ by 

 

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);
 hosted with 
❤ by 

 

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
  }
  }
  }
  }
 hosted with 
❤ by 

 

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);
 hosted with 
❤ by 

 

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

转载地址:http://liyga.baihongyu.com/

你可能感兴趣的文章
我的友情链接
查看>>
.JDK1.6安装配置后的测试
查看>>
判断闰年的函数
查看>>
pkill -9 nginx
查看>>
关于ASP.NET MVC4 Web API简单总结
查看>>
BGP最新的AS号:4-byte-as 转换为十进制及AS号兼容性
查看>>
Windows2008server R2 组策略批量更改本地管理员密码
查看>>
ubutnu安装geany
查看>>
webservice 之 Java CXF实战效果 RS WS(一)
查看>>
我的友情链接
查看>>
Repository 与 DAO
查看>>
Zabbix监控Windows主机
查看>>
IBM x3850 RAID5数据恢复方案及过程
查看>>
移动计算领域五大机遇:交通运输优势待挖掘
查看>>
如何把win7 旗舰版升级到sp1最新版本
查看>>
android 调用系统界面
查看>>
Software Enginering-------using git
查看>>
浅谈IP地址-1
查看>>
我的友情链接
查看>>
C#中的线程池使用(一)
查看>>