PaymentResponse: toJSON() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The toJSON() method of the PaymentResponse interface is a serializer; it returns a JSON representation of the PaymentResponse object.

Syntax

js
toJSON()

Parameters

None.

Return value

A JSON object that is the serialization of the PaymentResponse object.

Examples

Using the toJSON method

In this example, calling paymentResponse.toJSON() returns a JSON representation of the PaymentResponse object.

js
payment.show().then((paymentResponse) => {
  console.log(paymentResponse.toJSON())
  };
});

To get a JSON string, you can use JSON.stringify(paymentResponse) directly; it will call toJSON() automatically.

Specifications

No specification found

No specification data found for api.PaymentResponse.toJSON.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

Browser compatibility

BCD tables only load in the browser

See also