Set dynamically amount

I am implementing Android Payments SDK and I would like to know, how can I change charging amount from default 1$ to 3 options for example 10$, 15$, 20$? It dependence which option user choose. I know this topic already was here but from that answer I still dont know what to do. What to change in code?

Hi @Johnny,

Currently all out examples have the amount hard coded however you can choose to pass in the amount you want to charge your customer the best way that fits your application.

Hi @Bryan-Square
Can you tell me how can I do that? Because I use this Heroku server GitHub - square/in-app-payments-server-quickstart: In-App Payments Server Example where is hard coded that amount and when I make POST request to /chargeForCookie it charge me 1$ and I understand this. But What request should I do for different amount? Can you give me some example, hint ?

With the In-App Payment example it generates a nonce to pass to the payment request in the example server. If you are totaling the amount with the nonce creation you can pass it to the payment request just as the example sends the nonce from the client side to the server side. :slightly_smiling_face:

Hi @Bryan-Square,
Sorry, but I dont know What you mean, when you saying: If you are totaling the amount with the nonce creation. If I am not wrong, nonce I get from cardDetails and nonce it is just string which look like some key. So How should I totaling the amount with the nonce?
maybe these are stupid questions, but I am new in programming and I never met with this

Snímka obrazovky 2021-06-02 135343

Sorry if that wasn’t entirely clear. At some point in your application you will come up with the total amount to charge your customer. Whether you create an order using our Orders API or your own custom function. However you do this is entirely up to you. Once you have the total amount to charge you can pass that to the payment request along with the nonce once it’s been generated to process the payment.