How payment methods work in the Payment Request API
Tags: webpayments, paymentrequestapi, payments
Published: 2017-11-17 10:28:00

---
title: "How payment methods work in the Payment Request API"
published: true
tags: web-payments,payment-request-api,payments
canonical_url: https://medium.com/dev-channel/how-payment-methods-work-in-the-payment-request-api-54b8f2ee03c5
---

The Payment Request API makes it easy for a browser to pass known credit card details to a merchant. The API can also accept payments through apps which process payments anyway they wish, e-money, bank transfers, bitcoins, etc.

This article explains how payment method concept in the Payment Request API works so you can get a better view of the future of the Web Payments and possibly develop your own payment&nbsp;method.

Let’s dive&nbsp;in.

### **Payment methods are like plugins for Payment Request&nbsp;API**

The first argument you give to the [Payment Request API](https://w3c.github.io/payment-request/) is a sequence of payment&nbsp;methods.

[Each payment method](https://developers.google.com/web/fundamentals/payments/deep-dive-into-payment-request#defining_supported_payment_methods) consists of a required [payment method identifier](https://w3c.github.io/payment-method-id/) (supportedMethods) and an optional detail of the payment method&nbsp;(data).

In following example code snippet we declare 2 payment&nbsp;methods:

- The basic cards; Visa, Master, JCB: basic-card
- Android app that is built to integrate with the Payment Request API: https://bobpay.xyz

```
var methodData = [{
 supportedMethods: ‘basic-card’,
 data: {
   supportedNetworks: [‘visa’, ‘master’, ‘jcb’]
 }
}, {
 supportedMethods: ‘https://bobpay.xyz'
}];
```

A merchant can provide these as acceptable payment methods, so when a customer is visiting the site they will see the cards and apps filtered by the ones that are available to the user and select one to make a&nbsp;payment.

![](https://cdn-images-1.medium.com/max/473/1*8U7xtaTaUKtTL_5p7ux9TA.png)

### Payment Method Identifiers

There are two types of payment method identifiers:

- Standardized payment methods, e.g., “basic-card”
- URL-based payment methods, e.g., “https://bobpay.xyz”

#### Standardized payment&nbsp;methods

The Payment Request API example code illustrates that “basic-card” must be the most commonly used string for a payment method identifier. This is categorized as a standardized payment method and it’s actually supported by all browsers by default that implement the Payment Request&nbsp;API.

- [Payment Method: Basic Card](https://w3c.github.io/payment-method-basic-card/) (basic-card): A payment method that provides credit, debit and prepaid card payment information.

You can provide detailed definition by adding data property to the payment method data. supportedNetworks indicates which [credit card brand](https://www.w3.org/Payments/card-network-ids) you support and supportedTypes indicates which [type of cards](https://w3c.github.io/payment-method-basic-card/#basiccardtype-enum) ( credit, debit and prepaid) are supported.

As you can imagine, there’s [a registry of payment methods in the spec](https://w3c.github.io/payment-method-id/#registry) for standardized payment methods. basic-card is one example, but as of October 2017, no others exist yet in the registry. A few candidates are under active discussions:

- [Basic Credit Transfer Payment](http://w3c.github.io/webpayments-methods-credit-transfer-direct-debit/) (basic-credit-transfer): A payment method to transfer money between bank accounts.
- [Tokenized Card Payment](https://w3c.github.io/webpayments/proposals/interledger-payment-method.html) (tokenized-card): A payment method that provides tokenized card information.
- [Interledger Payment Method](https://w3c.github.io/webpayments/proposals/interledger-payment-method.html) (interledger): A payment method that transfers money using [the interledger protocol](https://interledger.org/).
- [Basic SEPAmail Payment](https://w3c.github.io/webpayments/proposals/sepamail) (sepamail): A payment method that supports payment by SEPAmail Applications such as RUBIS, GEMME or&nbsp;JADE.

#### URL-based payment&nbsp;methods

URL-based payment methods are usually represented using a URL string such as “https://google.com/pay" or “https://www.alipay.com/webpay". They represent a payment method and are usually tied with a particular payment app; but they don’t necessarily represent a one-to-one relationship. It’s totally possible one payment method is supported by multiple payment apps, or one payment app supports multiple payment&nbsp;methods.

For example, a third party payment app can support the basic-card as well as its specific https://bobpay.xyz payment&nbsp;method.

Unlike standardized payment methods, URL-based payment methods have no registry of payment methods. Anyone can develop and provide their own payment apps that support the payment method. This allows the Web Payments concept to develop a huge payment ecosystem on the&nbsp;web.

If you are interested in developing your own payment app, checkout [Payment Method Manifest](https://w3c.github.io/payment-method-manifest/) and see how a URL-based payment method identifier is converted to a concrete payment method. As of October 2017 only Android native payment apps are officially supported on Chrome, but web based payment apps support is coming&nbsp;too.

Android native payment apps specification is not standardized since it’s operating system specific, but [an integration guide can be found here](https://docs.google.com/document/d/1izV4uC-tiRJG3JLooqY3YRLU22tYOsLTNq0P_InPJeE/edit#). Check it out if you are interested in developing your own payment apps for Web Payments ecosystem.

### **Summary**

The concept of payment methods in Payment Request API is quite simple, but it is extremely important to understand the larger architecture. Hopefully many payment apps will emerge to make the Web Payments ecosystem more flexible and&nbsp;usable.

* * *