I’m looking into taking payments through the Square connect API on a website, but I can’t figure out how to allow the user to key in any payment amount they wish (like a PayPal pay me button). Is this possible to do, or can you only take payments in pre-set fixed amounts via Square?
It looks like in Square’s examples the amount is being set in the backend code and there’s no way to send the amount for the transaction through from the frontend.
I am following Square’s walkthrough using Node here: https://developer.squareup.com/docs/payment-form/payment-form-walkthrough
Apologies if this has been asked before, but I couldn’t find anything recent that addressed the issue.
4
Answers
I ended up solving this by coding the fetch to
/process-payment
explicitly in the frontend .js code instead of having it in the form submit so it looks like this:I posted a full working example of this here.
If you want to send the amount from the frontend, you would need to submit it via a field in a form (like the nonce in the example you provided). Ie if you wanted the customer to fill out the amount you would have something like:
as a field in your form, and then in your backend retrieve it from the
amount
name (which depends on what backend language you’re using, but as an example PHP would be something like$_POST['amount']
.Yes i face the same issue but i made the solution.
Firstly You make a hidden type field and give them some value e.g 100
add this line in below your form.Then go to payment-processing page,
**
**
get that input value i am doing in c# so its a c# code.
then pass this am string type variable to Amountmoney section. like below.
Here is the full code: