Using the Payment Request API with Moltin

Jonathan Steele
-
27
Sep
2017
Last updated:
27
Sep
2017

Let's learn how to standardize your checkout flow across the web with the new Payment Request API and Moltin.

Flaws of the checkout flow

The rise of online shopping has provided millions worldwide with the convenience of buying groceries, hot fashion trends and the latest gadgets all from the comfort of their own living room. But the process of paying for an order is often a frustrating and painful customer experience, resulting in 7 out of 10 shoppers abandoning their cart before completing payment.

A total inconvenience

So why is there such a high level of cart abandonment across the web? The checkout process is a friction point for users. In the age of Amazon, Netflix, and Postmates, your customers want an instant one-click checkout solution. Normally, there are multiple steps to complete before your order is finalized:

Sign in or register for an account unique to this retailer.

Add a payment card.

Add a billing address.

Add a shipping address, if different from billing.

Confirm the order and pay.

This level of input and repetition, especially on mobile, is a hindrance to customers. Pair that with a general level of inconsistency across checkout forms, different levels of validation and unsupported payment types and you have a frustrating experience that will drive your customers elsewhere (or insane).

Not only that, developing and maintaining a custom checkout flow and validation rules is also a time-consuming investment for your business.

If only there was a solution designed to alleviate all these flaws…

Introducing the Payment Request API

The Payment Request API is designed to standardize the checkout process across the web. Using the API requires significantly less attention and resources from you as a business owner, allowing you to focus on what matters. More importantly, it provides a faster, more consistent and less confusing experience for your customers.

The Payment Request API is vendor agnostic, meaning it is not tied to a specific payment system or processor. This allows for direct integration within the Moltin checkout flow using our supported gateways: Stripe and Braintree.

Useful links to learn more

What is the point of it then?

You maybe be asking yourself ‘if it doesn’t handle the actual payment, then what DOES it do?’. The API is designed to be a standardized UI flow for capturing customer and payment details, which you can then pass on to your payment system. It aims to simplify the current checkout process by implementing some basic enhancements:

UI for users to select addresses and payment information from their Google, Microsoft accounts.

Breakdown of their order including items, discount, and taxes.

Select from provided shipping options.

Standardized level of input and validation UI.

Support for a plethora of payment methods.

Works on any browser, device or platform.

The new Payment Request API can integrate directly with your existing store. Customers shop as they do now. When ready to pay, the merchant website would call the Payment Request API, which captures the required customer information ready to be sent to the payment gateway.

Best of all, because of the flexibility of the API and Moltin, the two can be integrated seamlessly.

Let’s see how.

Integrating with Moltin

The below example assumes an understanding of basic JavaScript concepts and uses the JavaScript SDK for API interaction.

Let’s assume that our fictional Moltin store has seen an increase in cart abandonment. We want to decrease the friction customers face between adding one of our products to a cart and paying for the order by reducing the steps in the checkout process.

To test this hypothesis, we’ve decided to build a ‘one click’ checkout button, integrating the new Payment Request API directly into the Moltin checkout flow. The steps will be as follows:

Customer adds a product to their cart.

We display a ‘one click’ checkout button in the UI.

On click of the button, we construct a new Payment Request object, passing in the required arguments.

Show the Payment Request UI to capture the customer details.

Checkout the Moltin cart using the data returned from the Payment Request API.

Pay for the order using the data returned from Moltin and Payment Request API.

Let’s go ahead and populate our cart with a product ready for purchase.

Next, we pass in theitems to display, which are cart items returned from the Moltin API. This allows us to show a breakdown of the order cost in the Payment Request UI.

Finally, theoptional third argumentis an object specifying what, if any, additional information is required from the customer. We want to get their name and email address in order to create an order with Moltin.

We can now call the `show()` method on ourPaymentRequestobject to display the UI. Here the customer will provide their information (billing details, addresses) required to complete the purchase. Theshow()promise will resolve when the customer completes the form. Once resolved, it will return an object containing the payment and address information collected from the customer in the UI. From here we can massage the response to match the expected Moltin request payload to complete our order and payment.

Once those requests have completed successfully, we need to call thecomplete()method on ourPaymentRequestobject to finish the flow and hide the UI.

// Complete the `PaymentRequest`return paymentResponse.complete();

That's it! You've integrated Moltin with the Payment Request API.

Summary

Rather than implementing a custom checkout and payment process, we managed to implement a native, frictionless checkout flow with a consistent UI with just a few lines of code. This vendor agnostic approach allows for the API to be used with virtually any payment processor or platform, as we’ve demonstrated above with Moltin.

The only downside is that the Payment Request APIbrowser coverageright now is limited, with only Chrome (61+) and Edge (15+) having support. However as support becomes more widespread, we expect more and more vendors to adopt this new technology, with this becoming the new wave for payments, globally.