PaymentRequest

An object that represents an Apple Pay or Google Pay payment request

PaymentRequest encapsulates the details of an Apple Pay or Google Pay request for payment and a method for connecting event listeners to the payment request.

Methods

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);