Hi, I need help with function in the client side

navehmevorach
Contributor
Contributor

So I having trouble to redirect the customer to a new page after the process is done

 

this is my code so far and I will love to understand how i redirecting the client to a new page using a node server
Thanks!!

 

paypal
  .Buttons({
    style: {
      color: 'blue',
    },
    onInit: function(data, actions) {
      actionStatus = actions
      actionStatus.disable()
    },
    onClick: function(data, actions) {
      url = searchInput.value
      const isURL = validURL(url)
      if (isURL) {
        // Remove Existing Error message
        if (searchInput.nextElementSibling.classList[1]) {
          searchInput.nextElementSibling.classList.remove('err-message--show')
        }

        // Calculate the price
        const photoAmount = document.querySelector('.header__photos').value * 1
        price = String(0.9 * photoAmount)        

        // Enable The Paypal Button
        actionStatus.enable()
      } else {
        searchInput.nextElementSibling.classList.add('err-message--show')
      }
    },
    enableStandardCardFields: true,
    createOrder: function(data, actions) {
      return actions.order.create({
        purchase_units: [
          {
            amount: {
              value: price,
              currency_code: 'ILS'
            }
          }
        ]
      })
    },
    onApprove: function(data, actions) {
      return actions.order.capture().then(function(details) {
        alert('Transaction completed by ' + details.payer.name.given_name)
        // Call your server to save the transaction
        return axios.post('/paypal-transaction-complete', {
          orderID: data.orderID,
        })
      })
    },
    onError: function(err) {
      // Show an error page here, when an error occurs
      console.log('error')
      }
  })
  .render('#paypal-button-container')
Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.