if (window.PaymentRequest) {
// We're good to go...
} else {
// Alas! Use your legacy checkout form...
}
var methodData = var methodData = [{
// NB. To support older format, include networks here
supportedMethods: ['basic-card'],
data: {
// Examples. Others are available too!
supportedNetworks: ['visa', 'mastercard', 'amex']
}
}];
var details = {
total: {
label: 'Socks',
amount: {currency: 'GBP', value: '12.00'}
}
};
// Show the payment UI and handle the result
new PaymentRequest(methodData, details)
.show()
.then(function(uiResult) {
myPaymentProcessor(uiResult);
})
.catch(function(error) {
myErrorHandler(error);
});
var details = {
displayItems: [
{
label: "Socks",
amount: { currency: "GBP", value : "12.00" },
},
{
label: "Loyalty discount",
amount: { currency: "GBP", value : "-1.00" },
}
],
total: {
label: 'Total',
amount: {currency: 'GBP', value: '11.00'}
},
...
...
shippingOptions: [
{
id: 'standard',
label: 'Standard shipping',
amount: {currency: 'GBP', value: '1.50'},
selected: true
}
]
};
var options = {
requestPayerName: true,
requestPayerEmail: true,
requestPayerPhone: true,
requestShipping: true
};
new PaymentRequest(methodData, details, options)
...
Chrome for Android v53+ | Samsung Internet v5.0+ | Edge Preview |