W3cubDocs

/Web APIs

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

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.

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

This feature does not appear to be defined in any specification.>

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
toJSON 60 15 55 47 11.1 55 No 42 11.3 6.0 No 11.3

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PaymentResponse/toJSON