mfahadi
mfahadi

Reputation: 419

Braintree - Hosted Fields PayPal amount unable to change

I am using Braintree Hosted Fields for checkout. I have added Paypal button like this

paypal: {
            container: "paypal-container",
            amount: 20.00,
            singleUse: true,
            currency: 'EUR',
        }

I want the customer to enter the amount as much as he wants. I have checked the docs but unable to find how it can be done with hosted fields.

One option I have is to refresh the page once customer change the amount in the form text fields but that will wasted a lot of time.

Upvotes: 1

Views: 235

Answers (1)

Mimarshall
Mimarshall

Reputation: 442

Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.

One way to do this is to have a two step process. Have the user provide the amount prior to calling braintree.setup. Once they enter the value, you can call braintree.setup in javascript, using the same parameters you currently have but setting the amount parameter to be whatever the user just entered. The user can then go through the rest of the authorization flow, and you can send the amount to your server, which will be used in a Brantree.Transaction.sale call to complete the purchase.

Upvotes: 1

Related Questions