getSupportedPaymentMethods()

Get a list of supported payment methods for the specified device and verify whether the device supports Tap-To-Pay.

Syntax 

1import { getPaymentsService } from 'lightning/mobileCapabilities';
2getSupportedPaymentMethods(options:
3GetSupportedPaymentsMethodsOptions): Promise<[String]>

Parameters 

  • countryIsoCode–(Required) A text field that represents the currency ISO code.
  • merchantAccountId—(Required) A text field that represents the ID of the Merchant Account object.
  • permissionRationaleText–(Optional) A text field that’s presented to the user in case permission is missing (for example, location permission) and must be requested from the user. Defaults to a predefined text if it’s empty.

Returns 

A Promise object that resolves to an array of string values. The values are available payment methods supported for the specific running device (for example, ["TAP_TO_PAY"]). If there’s an error, a rejected promise returns the error type of PaymentsServiceFailure.

Usage 

1myPaymentsService
2  .getSupprtedPaymentMethods(options)
3  .then((results) => {
4    const supportedPayments = JSON.parse(JSON.stringify(results, undefined, 2));
5    const msg = `Available Payment Methods: ${supportedPayments}`;
6    console.log(msg);
7  })
8  .catch((error) => {
9    const msg = `Failed to get supprted payment methods: ${JSON.stringify(
10      error
11    )}`;
12    console.log(msg);
13  });