public/js/gpay.js
/**
     * Handles authorize payments callback intents.
     *
     * @param {object} paymentData response from Google Pay API after a payer approves payment through user gesture.
     * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentData object reference}
     *
     * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentAuthorizationResult}
     * @returns Promise<{object}> Promise of PaymentAuthorizationResult object to acknowledge the payment authorization status.
     */
Handles authorize payments callback intents.
@param {object} paymentData response from Google Pay API after a payer approves payment through user gesture.


Handles authorize payments callback intents . @param { object } paymentData response from Google Pay API after a payer approves payment through user gesture .
function onPaymentAuthorized(paymentData) {
      return new Promise(function(resolve, reject){
        //
        processPayment(paymentData)
          .then(function() {
            resolve({transactionState: 'SUCCESS'});
          })
          .catch(function() {
            resolve({
              transactionState: 'ERROR',
              error: {
                intent: 'PAYMENT_AUTHORIZATION',
                message: 'Insufficient funds, try again. Next attempt should work.',
                reason: 'PAYMENT_DATA_INVALID'
              }
            });
            });
      });
    }
function onPaymentAuthorized ( paymentData ) { return new Promise ( function ( resolve , reject ) { ocessPayment(p a ymentData) . then ( function ( ) { resolve ( { transactionState : 'SUCCESS' } ) ; } ) . catch ( function ( ) { resolve ( { transactionState : 'ERROR' , error : { intent : 'PAYMENT_AUTHORIZATION' , message : 'Insufficient funds, try again. Next attempt should work.' , reason : 'PAYMENT_DATA_INVALID' } } ) ; } ) ; ) ; }
Handles authorize payments callback intents.
Handles authorize payments callback intents .
 handle the response