Sap1234
Sap1234

Reputation: 147

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');
   }
}

Upvotes: 1

Views: 234

Answers (1)

Preston PHX
Preston PHX

Reputation: 30477

value: some_function_call_that_returns_value_you_want();

For instance:

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

Upvotes: 1

Related Questions