Page Summary
-
The
PaymentRequestobject facilitates web payments by encapsulating payment instrument details, order information, and optional settings. -
Payment request functionality depends on browser support, and the object will be null if the API is unavailable, prompting a fallback mechanism.
-
Developers can construct a
PaymentRequestusing supported payment instruments and order details, while handling potential errors gracefully.
The PaymentRequest
object is constructed by defining the following:
- Payment instrument.
- Order details.
- Options.
If payment request API isn't supported in the customer’s browser, the created object will be null.
Create a payment request
The following code snippet illustrates how to create a PaymentRequest
object.
let
request
=
null
;
try
{
request
=
new
PaymentRequest(supportedInstruments,
details)
;
}
catch
(
e
)
{
console.log('Payment
Request
Error
:
' + e.message);
return;
}
if (!request) {
console.log('
Web
payments
are
not
supported
in
this
browser
.
'
);
return
;
}

