Search code examples
extjspaypalrender

How to change the amount value of PayPal button in extjs?


I put PayPal button in afterrender event of container, but the problem is that the amount value is fixed at that point and I cannot figure out how this value can be changed. So, how the value ('88.44') can be changed dynamically in EXTJS?

listeners:{
           
   afterrender: function (){

        paypal.Buttons({

            // Set up the transaction
            createOrder: function(data, actions) {
                return actions.order.create({
                    purchase_units: [{
                        amount: {
                            value: '88.44'
                        }
                    }]
                });
            },

            // Finalize the transaction
            onApprove: function(data, actions) {
                return actions.order.capture().then(function(details) {
                    // Show a success message to the buyer
                    alert('Transaction completed by ' + details.payer.name.given_name + '!');
                });
            }


        }).render('#paypal-button-container');
   }
}

Solution

  • value: some_function_call_that_returns_value_you_want();
    

    For instance:

    value: document.getElementById('amount').value;