MODULES
...
eCommerce
Cart, Checkout, Shipping and O...
Basic Payment Forms - Tutorial
16min
basic payments are a way to take a payment when a form is submitted they may be useful for allowing users to pay invoices etc prerequisites you have installed the ecommerce module in site settings you have set up a payment gateway using paypal as a payment gateway? there are additional setup instructions here introduction basic payments are a way to take a payment against a standard form submission you set the currency, and the minimum payment value in form builder when submitting the form, a value is sent to our payment processor, and validated server side to check that it's higher than the minimum payment value you have set here's 3 examples of when you'd use this payment system if you're sending invoices to a customer, and want them to pay online, they can enter their invoice number (in a custom field) and the amount to pay you would then check 'offline' that the value paid matches that on the invoice in this case you'd set the minimum payment value as '0 00' you know the exact value you want the users to pay (for example $10 00), so you set the minimum payment value as '10 00' this is validated server side to make sure they cannot pay less than that you want to charge a variable amount based on their form selections, and know the minimum value that should be for example, the charge might be $10 00 as standard, but then have some optional custom fields that bring the price up to $20 00 see the section below "changing the price based on user form input" setting up a basic payment form with a fixed payment amount the following steps are for setting up a basic payment form which will accept a fixed payment amount e g all customers submitting the form will pay the same the same steps should also be followed if you intend the amount paid to be decided based on the user's interaction with the form but there will be additional steps described below step 1 payment gateways basic payment is available using the following payment gateways stripe paypal authorize net note depending on the payment gateway, some specific fields may be needed in order to capture the necessary payment details those fields will be specified in step 5 step 2 (optional) secure zones in order to use secure zones in this process, they first need to be set up for instructions on how to use secure zones on a form, click here if you apply a secure zone to the form, then the user will be given access after a successful payment step 3 create a form when creating a form, navigate to the 'payments' tab here you should enter the following data use as a payment form? toggle to 'true' payment form type basic payment form currency choose from the dropdown of supported currencies minimum payment value the minimum amount a user can pay to submit this form for further instructions on how to set up forms, click here step 4 (optional) editing your form layout to apply payment gateway specific code please see below for code relevant to your payment gateway stripe there is no extra code required for stripe authorize net http //authorize net you must include 3 extra fields for authorize net http //authorize net to work field name example notes card number \<input id="s e card num" class="required" type="text" /> card expiry \<input id="s e card exp" class="required" type="text" placeholder="mm yyyy" /> the data format must follow that in the placeholder in our example card cvv \<input id="s e card cvv" class="required" type="text" /> step 5 testing to test your new basic payment form, you first must put it on a page you can do so using toolbox's 'insert form' feature once you have created a page and navigated to it, you will need to fill in the fields and submit if your payment gateway is in 'test mode', then you may need to enter card details specific to the testing environment you can find those under 'test cards' on our payment gateways documentation page changing the amount to be paid based on the user's form input in some use cases you may wish the amount to be paid to depend on the user's input into the form fields e g the user is making charitable donations the minimum payment is $2, but they can choose to donate any amount above that they wish the user will select options on the form that will inform a logical function to decide how much they need to pay both use cases will require you to write a javascript function which will update the value of the amount due using liquid to fetch the currency and minimum amount from admin you may find the following liquid tags helpful while developing liquid role example {% include 'ecommerce/basic payment currency' %} the currency for the form defined in admin gbp {% include 'ecommerce/basic payment currency', format 'symbol' %} the symbol for the currency for the form defined in admin £ {% include 'ecommerce/basic payment min amount' %} the minimum payment value defined in admin, in the lowest denomination of that currency 100 {% include 'ecommerce/basic payment min amount', format 'decimal' %} the minimum payment value defined in admin, formatted 1 00 writing the function the end goal of such a javascript function will be to set the value of hidden field with the id "s e amount" the default value of this field will be the same as the minimum payment value you set in admin, until it is changed via javascript the final value should be an integer (whole number) of the number of cents that will be paid we'll give you an example of how this javascript may work here you can adapt this example to suit your use case the important thing is that you set the value of the field with the id "s e amount" example allowing the user to enter any value they wish the following example allows the user to enter an amount of their choice into an input in the form our function changes the format, then sets the value of the hidden field note that the entire example should sit inside a liquid {% form %} tag how much can you afford to donate (pounds and pence e g 10 00)? {{context exports currency map data\['gbp']}} example using url parameters to change the value of s e amount this example shows how you can add an "amount" parameter to the url if this parameter exists then the s e amount will be updated the following javascript can be added to your basic payment form's layout the first half of the function will store the amount parameter within the "amount" variable, the second half checks if "amount" exists (this prevents "null" from getting added to s e amount ) if so then s e amount is updated with the new price window\ addeventlistener('domcontentloaded', (event) => { //fetch amount param from the url const urlparams = new urlsearchparams(window\ location search); const amount = urlparams get('amount'); //set s e amount value to amount from url param if(amount) { document queryselector('#s e amount') value = amount; }; }); a note on security remember, this kind of payment is designed for use cases where the customer intends to make a charitable donation or pay an invoice that is due it is possible for the customer to modify the javascript and pay less (but not less than the minimum payment value) you should only use this kind of payment either when the customer does have a genuine choice, or the client will be reconciling invoices and chasing where the correct amount has not been paid related articles basic payment forms are just one of the ways that siteglide ecommerce can take payments from customers you can also use checkout subscriptions