#
PaymentRequest
#
An object that represents an Apple Pay or Google Pay payment request
PaymentRequest
encapsulates the details of an Apple Pay, Google Pay, or Afterpay/Clearpay request
for payment and provides a means of listening for shipping option and shipping
contact changes via event listeners.
A PaymentRequest can be constructed by calling payments.paymentRequest.
The event listeners for Afterpay/Clearpay are specific to that payment method.
Methods
paymentRequest.js
JS
JavaScript
const payments = Square.payments(appId, locationId);
const paymentRequest = payments.paymentRequest({
countryCode: 'US',
currencyCode: 'USD',
requestBillingContact: true,
requestShippingContact: true,
lineItems: [
{ amount: '2.00', label: 'Item Cost' },
{ amount: '0.00', label: 'Shipping' },
{ amount: '0.00', label: 'Tax' },
],
shippingOptions: [
{
amount: '0.00',
id: 'shipping-option-1',
label: 'Free',
},
],
total: {
amount: '1.00',
label: 'Total',
}
});
const applePay = await payments.applePay(paymentRequest);
const googlePay = await payments.googlePay(paymentRequest);