The PaymentRequest()
constructor creates a new PaymentRequest
object which will be used to handle the process of generating, validating, and submitting a payment request.
new PaymentRequest(methodData, details)
new PaymentRequest(methodData, details, options)
A new PaymentRequest
object, configured for use as configured by the input parameters.
The following example shows minimal functionality and focuses instead on showing the complete context of instantiating a PaymentRequest
object.
const supportedInstruments = [
{
supportedMethods: "https://example.com/pay",
},
];
const details = {
total: { label: "Donation", amount: { currency: "USD", value: "65.00" } },
displayItems: [
{
label: "Original donation amount",
amount: { currency: "USD", value: "65.00" },
},
],
shippingOptions: [
{
id: "standard",
label: "Standard shipping",
amount: { currency: "USD", value: "0.00" },
selected: true,
},
],
};
const options = { requestShipping: true };
try {
const request = new PaymentRequest(supportedInstruments, details, options);
request
.show()
.then((instrumentResponse) => {
})
.catch((err) => {
});
} catch (e) {
}