hosted-fields/public/buttons.js
// Finalize the transaction after payer approval
Finalize the transaction after payer approval
Finalize the transaction after payer approval
async onApprove(data, actions) {
      const orderData = await api.captureOrder(data.orderID);
      console.log(
        "Capture result",
        orderData,
        JSON.stringify(orderData, null, 2)
      );
      var transaction = orderData.purchase_units[0].payments.captures[0];
      alert(`Transaction ${transaction.status}: ${transaction.id}
        See console for all available details
      `);
    }
async onApprove ( data , actions ) { const orderData = await api . captureOrder ( data . orderID ) ; console . log ( "Capture result" , orderData , JSON . stringify ( orderData , null , 2 ) ) ; var transaction = orderData . purchase_units [ 0 ] . payments . captures [ 0 ] ; alert ( ` ${ transaction . status } ${ transaction . id } ` ) ; }
Finalize the transaction after payer approval
Finalize the transaction after payer approval
// Successful capture! For dev/demo purposes: // When ready to go live, remove the alert and show a success message within this page. For example: // var element = document.getElementById('paypal-button-container'); // element.innerHTML = '<h3>Thank you for your payment!</h3>'; // Or go to another URL:  actions.redirect('thank_you.html');