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"));
view raw configuration.java hosted with  ❤ by  GitHub

 

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 raw intent.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
 }
 }
 }
 }
view raw activityresult.java hosted with  ❤ by  GitHub

 

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);
view raw correlationid.java hosted with  ❤ by  GitHub

 

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

转载于:https://www.cnblogs.com/android-blogs/p/6409212.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
很高兴为您解答这个问题。下面是使用HTML和CSS编写的广播电视学专业介绍网站。 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Broadcasting and Television Studies</title> <style> /* CSS样式 */ body { font-family: Arial, sans-serif; } header { background-color: #0099cc; color: #fff; padding: 20px; text-align: center; } nav { background-color: #e1e1e1; padding: 10px; } nav ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; } nav li { float: left; } nav li a { display: block; color: #000; padding: 8px 16px; text-align: center; text-decoration: none; } nav li a:hover { background-color: #cccccc; } section { margin: 20px 0; } h1 { font-size: 36px; margin-bottom: 10px; } h2 { font-size: 24px; margin-bottom: 10px; } table { border-collapse: collapse; width: 100%; } th, td { text-align: left; padding: 8px; border-bottom: 1px solid #ddd; } th { background-color: #0099cc; color: #fff; } .container { width: 80%; margin: 0 auto; } footer { background-color: #ccc; color: #fff; padding: 20px; font-size: 14px; text-align: center; } </style> </head> <body> <header> <h1>Broadcasting and Television Studies</h1> <p>Explore the world of broadcasting and television with us.</p> </header> <nav> <div class="container"> <ul> <li><a href="#introduction">Introduction</a></li> <li><a href="#curriculum">Curriculum</a></li> <li><a href="#books">Books</a></li> <li><a href="#skills">Skills</a></li> <li><a href="#career">Career</a></li> </ul> </div> </nav> <main> <div class="container"> <section id="introduction"> <h2>Introduction</h2> <p>Broadcasting and Television Studies is a field that combines both theoretical and practical aspects of television and radio broadcasting. This field covers a wide range of topics including multimedia production, journalism, advertising, and media management.</p> </section> <section id="curriculum"> <h2>Curriculum</h2> <table> <tr> <th>Course</th> <th>Credits</th> </tr> <tr> <td>Introduction to Broadcasting and Television Studies</td> <td>3</td> </tr> <tr> <td>Media Production</td> <td>3</td> </tr> <tr> <td>Journalism</td> <td>3</td> </tr> <tr> <td>Advertising</td> <td>3</td> </tr> <tr> <td>Media Management</td> <td>3</td> </tr> </table> </section> <section id="books"> <h2>Books</h2> <ul> <li>Television Production Handbook by Herbert Zettl</li> <li>Broadcast Announcing Worktext by Alan R. Stephenson</li> <li>Media Ethics: Issues and Cases by Philip Patterson and Lee Wilkins</li> </ul> </section> <section id="skills"> <h2>Skills</h2> <ul> <li>Video and audio editing</li> <li>Scriptwriting</li> <li>On-camera and voiceover performance</li> <li>Radio and television production</li> <li>Advertising and public relations</li> </ul> </section> <section id="career"> <h2>Career</h2> <p>Graduates of Broadcasting and Television Studies can pursue a variety of careers in the media industry including broadcast journalism, production management, advertising, public relations, and social media management. </p> </section> </div> </main> <footer> <p>Copyright © 2021 Broadcasting and Television Studies</p> </footer> </body> </html> 希望这个答案能够对您有所帮助,谢谢!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值