Checkout 3.0
Payment Method Changed Callback

Payment Method Changed Callback

Optional callback that allows a partner to get information about the changes to the currently selected payment method inside Checkout3.

Callback is triggered when a different payment method is selected in Checkout3 by the user.

Registering callback

To use this optional callback, a partner has to pass an additional flag paymentMethodChangedCallback to avardaCheckoutInit. Please refer to Showing the checkout form for additional info about Checkout 3 Form initialization.

Callback payload

Callback payload is an object with paymentMethod, paymentFee amd taxAmount properties as the first parameter and checkoutInstance as the second parameter (it is not necessary to use it).

  • paymentMethod is the name of the selected payment method, represented as a string
  • paymentFee is the fee amount for the selected payment method (including tax), represented as a number
  • taxAmount is the tax applied to the payment fee, represented as a number

The example below shows how to use these values in a callback function.

<script>
  const paymentMethodChangedCallback = function ({ paymentMethod, paymentFee, taxAmount }, checkoutInstance) {
    console.log('paymentMethod:', paymentMethod);
    console.log('paymentFee:', paymentFee);
    console.log('taxAmount:', taxAmount);
 
    // Use data for your business logic
  };
</script>