Tag Archives: SDK

Inside the PayPal Mobile SDK 2.0

By

We’re pleased to announce the 2.0 release of the PayPal Mobile SDK. This major version update introduces important new capabilities as well as improvements under the hood. In this post we’ll highlight a few of the major changes, with some narrative about how we got here.

TL;DR? Check out the PayPal Developer Docs for an overview. In-depth docs and SDK downloads can be found in the PayPal iOS SDK on GitHub or PayPal Android SDK on GitHub.

SDK Focus

In writing the first version of the Mobile SDK last year, our team focused on four high-level values:

  1. Fast and delightful user experience making payments
  2. Simple, equally delightful developer experience taking payments
  3. Consistent, bulletproof quality across devices and platforms
  4. Opendirecttechnical communication between developers (you!) and us

To keep the bar high, we limited the first SDK release to only single payments, using PayPal or credit card (with card.io scanning). While the developers looking for a basic drop-in payment library have found the first version helpful, we knew a complete native mobile payments solution needed to offer more. So, without losing focus on simplicity, quality, and community, we’ve written the 2.0 Mobile SDK to enable seamless commerce in modern, sophisticated mobile commerce and marketplace apps.

Future Payments

The marquee feature in 2.0 is Future Payments. With Future Payments, developers can gather payment information from a customer just once, and use it to process all future payments from that customer. If you’ve added PayPal as a payment option in Uber, then you’ve used it. Uber piloted this feature with us to provide their customers with a PayPal payment option that’s fast and simple. With 2.0, we’re opening up Future Payments to all mobile developers.

So how does it work? To identify who should get paid, you give the SDK a public Oauth2 client_id as input. The SDK then authenticates a user and asks for payment authorization; it returns a short-lived OAuth2 authorization code. Your app sends that authorization code to your servers. Your servers use this code to request OAuth2 access and refresh tokens with the future_payments scope. You can use the access token right away to charge the user, and store the refresh token for the future. Any time that you need to make payment API requests for this user in the future, you can exchange that refresh token for an access token, and you’re off to the races — no need to bother the user again.

Phew! It sounds more complicated than it actually is, and the SDK includes step-by-step integration guides:

Auth & Capture

One frequently requested feature is the option to decouple authorization of a payment from capture at a later time. This is a standard capability offered by credit card gateways. It is useful, for example, when shipping physical goods – you can authorize your customer’s payment when the order is placed, then later capture the funds only when the goods actually ship.

The 2.0 SDK uses new, flexible PayPal REST payment APIs – you can create a payment with either a sale or authorization intent. Thanks to the improved APIs, our team was able to add Auth/Capture support with only minor code changes. And, notably, the intent setting works identically for PayPal and credit card payments.

REST and OAuth 2.0

As PayPal continues to optimize mobile-first platform offerings, the PayPal Mobile SDK team works closely with counterparts in the API teams to set the roadmap and nail the integration with the OAuth2 Identity services and REST Payments API.

The 2.0 SDK now uses only the new PayPal APIs. Migrating to these APIs was critical to making the 2.0 SDK a reality. Now that we’re on the new stack, the SDK is well positioned to gain new capabilities in pace with the platform. We look forward to adding further improvements!

Check it Out

Learn more about the 2.0 PayPal Mobile SDKs by checking out the PayPal Developer Docs. When you’re ready to take a look at the APIs, sample code, README, and integration docs, head on over to GitHub:

We’d love to hear your integration experience and feedback.

About the PayPal SDK Team

We’re a distributed team (Portland, Austin, San Jose) that creates great tools for developers and delightful experiences for their users. When not releasing sweet PayPal SDKs, we can be found variously drinking copious amounts of coffee, writing science fiction, biking long distances, snuggling with a Ziggy, or driving down the California coast. Want to get in touch or see what we’ve worked on? Find us on GitHub: DaveBrentTomMattJeffJuwonAviJosh, AbhijeetMikeAvijit, Roman, and Bunty.

Announcing the new RESTful API Node.js SDK

By and

Since the launch of the new PayPal RESTful APIs, the development teams have been hard at work to provide the development community with new features and ways of working with our new initiatives.

With that said, I am happy to announce the launch of the new Node.js SDK for the RESTful APIs. As a Node.js developer myself, I am always happy to see how much eBay and PayPal support the Node.js community.

Getting the SDK As with all of our SDKs, the Node.js SDK is available on the

PayPal Github account. What makes this approach excellent for the community is that all issues and enhancements that users may want to contribute can be done directly through the Github project itself, meaning that the progress and work that the teams are doing to enhance the projects are completely transparent.

To find samples for working with the SDK, you can also take a look through the Node.js SDK sample repository. This is an excellent place to get started.

Using the SDK There are a few steps that we need to go through in order to integrate the SDK into a Node.js application.

1. Create the package.json file To start out an integration, we first need to create our package.json file that will give our application all of its configuration information.

The easiest way to get started is to copy the sample package.json file from the PayPal Node.js SDK Github repository. Once copied to your application folder, open it up for editing.

We now need to add the PayPal Node.js SDK as a dependency for our application. Go down to the dependencies object declaration and add a new paypal-rest-sdk definition. That section should now look like the following: "dependencies": {
"node-uuid": "*",
"paypal-rest-sdk": "*"
}
2. Install dependencies and create your test file With the package.json file created, we now need to use it to install our application dependencies. At the application folder root, where the package.json file is, simply run the following command: npm install Once completed, you should now see a new node_modules folder within your project, containing all of the required project dependencies. Next, go ahead and create a new Node.js application file, such as test.js, where we will put all of our test code. 3. Configure your application details Open up your new Node.js file to begin adding in our application configuration details. We’re going to start by creating a new variable for the SDK, paypal_sdk. With that in place, we then create a PayPal configuration object. This section will contain:
* host: The API host to use, api.sandbox.paypal.com for the PayPal sandbox, or api.paypal.com for live requests.
* port: The port to use.
* client_id: Your PayPal application client id.
* client_secret: Your PayPal application client secret.

4. Making your first request Now that the configuration object is in place, we can make our first request. Let’s go ahead and store credit card information in the vault. We start by creating a credit card object with the information that we want to store in the vault. Once that’s in place, we make a call to the credit_card.create method to initiate the storage request. Once the code is called, you should see a valid response coming back with the credit card store response, looking something like this:

Going Further To continue exploring the Node.js SDK and the methods available, you can take a look through the

SDK lib itself at the end of the file in the return structure, or see the API methods on the PayPal Developer site.

If you want to see what other SDKs are available, you can explore this earlier SDK announcement post.