Frontend JS

Step 1: Include our JS in your HTML page

Add the following code just before the closing body tag on your checkout page:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://gateway.breathepay.co.uk/sdk/web/v1/js/hostedfields.min.js"></script>

Step 2: Display the hosted payment fields with BreathePay

Add the following HTML form where you want to display the hosted payment field:

<form id="card-element" method="post" novalidate="novalidate" lang="en" >
    <input id="cardDetails">
</form>

Add a submit button that we'll use to submit the payments form later (place this outside of the above form):

<button type="button" id="submitButton">Pay Now</button>

Add a hidden form that will be used to submit the required information to your backend

<form id="paymentForm" action="YOUR_CHECKOUT_URL" method="post" style="opacity: 0;"> 
    <input type="text" id="token" name="paymentToken">
    <input type="text" id="browserInfo" name="browserInfo">
</form>

Step 3: Add your own Javascript file that gathers the required information and submits it to your backend

Step 4: Add a custom style sheet for your payment fields

Add a CSS file and link to it in the HEAD section of your HTML page

Add custom CSS styling to your stylesheet:

Last updated