Video Tutorials.


Adding the Payment iFrame to your web page

On this page:

1. Intro.

In this tutorial, we will add Judopay’s WebSDK Payment iFrame to a web page.

This iFrame renders a payment form, which can be used to capture and submit a consumer’s card details.

2. Importing and creating an instance of Judopay's Web SDK library.

In your head element, add the script tag to import Judopay’s web SDK library

<script src=""></script>

To automatically use the latest version, you can use 0.0, instead of the current patch version.

<script src=""></script>

In your script element, create an instance of the Judopay web SDK.

Set the first parameter to your API token, which should be the same as the one used when creating the payment session.

Ensure this value is your API token and does not also include the API secret.

var judo = new JudoPay(yourAPIToken, false)

For the second parameter, set to true to use the sandbox environment, and set to false to use the production environment.

3. Rendering the iFrame onto the web page.

In your body element add a <div> tag where you want the iFrame to appear.

<div id="payment-iframe" width="100%"></div>

This example uses the ID "payment-iframe", but you can use whatever ID you wish.  This ID will be used when rendering the iFrame.

In your script element, call create card details to render the payment iFrame in the <div> tag you defined earlier.


"payment-iframe", is the ID of the <div>,  where the iFrame will be rendered.

You should now see the Payment iFrame rendered on the page.

Note, the payment button for the form is not part of the iFrame. Adding the button to the page will be explained later in this tutorial.

4. Customising the iFrame.

In your body element, define the iFrame configuration object, which will be used to customise the look and behaviour of the iFrame.

Add the iFrame configuration object as the second parameter of the create card details call.

judo.createCardDetails("payment-iframe", iFrameConfiguration)

In this demo project, we copied the example iFrame configuration object available in Judopay's documentation.

We then made some adjustments to the object, in order to get the look and behaviour we desired.

Please see our documentation for more information on the customisation available.

On your web page, the look and behaviour of the payment iFrame should now have been updated.

5. Adding the payment button.

In your body element, add a button element where the ID must be set to "submit-payment-button".

<button id="submit-payment-button"> Pay Now </button>

You should now see the button on your web page.

You can apply any css styling you wish to this button.

If the ID of the payment button is set correctly, the button should be disabled until all the payment information has been duly entered.


6. Displaying payment form errors.

Payment form errors can be shown under the form fields and/or outside of the iFrame.

The property, errorsDisplay set in your iFrame configuration object, will affect where the payment form errors are shown.

Here are the values you can set for this property.

  • SHOW_ALL =  shown under fields and outside the iFrame
  • HIDE_UNDER_FIELDS  = shown outside the iFrame
  • HIDE_UNDER_FORM = shown under fields
  • HIDE_ALL = not shown

If you wish to show the payment form errors outside of the iFrame, the following will explain how to do so.

6a. [Optional] Rendering errors outside the iFrame.

In your body element, add a <div> tag where you want the payment form errors to appear.

<div class="judopay-errors"></div>

Ensure the class of the <div> matches the value of the property, errorFieldId, which is defined in the iFrame configuration object.

errorFieldId: 'judopay-errors',

You can add any custom style you wish to the error message.

7. Recap.

We now have a customised Judopay payment iFrame, rendered on our payment page, complete with a customised payment form, that has captured and validated the card details, and is now ready for the consumer to submit their card details.

See our next tutorial 'Handling a Transaction', which will guide you on how to submit the payment and handle the response.

Check out our Developer Documentation for more information on adding the payment iFrame to your page.

< Back to Video Tutorials