# Methods

See the following table to configure your payment page:

<table data-full-width="true"><thead><tr><th valign="top">Using this method…</th><th valign="top">You can…</th><th valign="top">Sample Code</th><th valign="top">Remark</th></tr></thead><tbody><tr><td valign="top"><code>addMetaKeyBlocker()</code></td><td valign="top"><p>Block meta key combinations (alt or ctrl) for the hosting page.</p><p>Some card readers may generate keystrokes that include meta keys even after the card read is complete, causing unnecessary behavior in the browser window.</p><p></p><p><mark style="background-color:green;"><strong>Tip</strong>:</mark> To make this setting effective, set the <code>enableReader</code> member to <code>True</code>.</p></td><td valign="top"><code>&#x3C;script> ClearentSDK.addMetaKeyBlocker(); &#x3C;/script></code></td><td valign="top">This setting blocks certain meta key combinations, except for closing the window (Ctrl + W), opening a new window (Ctrl + N), or opening a new tab (Ctrl + T).</td></tr><tr><td valign="top"><code>getPaymentToken()</code></td><td valign="top">Receive a token for payment gateway transaction, calling <code>successCallback</code> on success or <code>errorCallback</code> on error.</td><td valign="top"><code>ClearentSDK.getPaymentToken();</code></td><td valign="top">None</td></tr><tr><td valign="top"><code>init(obj)</code></td><td valign="top">Initialize the JavaScript SDK integration and create the Payment Details form for entry.</td><td valign="top"><code>// Sandbox URL for testing</code><br><code>// use Sandbox public key &#x3C;script src="https://gateway-sb.clearent.net/js-sdk/js/clearent-host.js">&#x3C;/script> &#x3C;script> ClearentSDK.init({ "baseUrl": "https://gateway-sb.clearent.net", "pk": "YOUR_SANDBOX_PUBLIC_KEY_HERE", }); &#x3C;/script></code></td><td valign="top">You can set the properties of the JSON-formatted object when you initialize the JavaScript SDK integration.</td></tr><tr><td valign="top"><code>removeMetaKeyBlocker()</code></td><td valign="top">Remove a meta key combination blocker enabled using the <code>blockMetaKeys</code> member or the <code>addMetaKeyBlocker</code> method.</td><td valign="top"><code>&#x3C;script> ClearentSDK.removeMetaKeyBlocker(); &#x3C;/script></code></td><td valign="top"> </td></tr><tr><td valign="top"><code>reset()</code></td><td valign="top"><p>Reset the JavaScript SDK integration.</p><p></p><p><mark style="background-color:red;"><strong>Warning</strong>:</mark> When you use the <code>reset()</code> method, the Xplor Pay Payment iFrame is completely removed.</p></td><td valign="top"><code>ClearentSDK.reset();</code></td><td valign="top">You can call <code>Clearent.init</code> to initialise the JavaScript SDK integration.</td></tr><tr><td valign="top"><code>ClearentCardReadComplete()</code></td><td valign="top">Call the function when the card read process is complete using the USB card reader.</td><td valign="top"><code>function ClearentCardReadComplete(){ console.log("Card Read is complete"); }</code></td><td valign="top">You can call the function if it is defined on the host page. This function does not return card data or Europay, Mastercard and Visa (EMV) data to maintain the Payment Card Industry (PCI) compliances.</td></tr><tr><td valign="top"><code>ClearentCardReadStart()</code></td><td valign="top">Call the function when the card read process starts using the USB card reader.</td><td valign="top"><code>function ClearentCardReadStart(){ console.log("Card Read has started"); }</code></td><td valign="top">You can call the function if it is defined on the host page.</td></tr><tr><td valign="top"><code>ClearentEntryModeChange(mode)</code></td><td valign="top">Call the function when the entry mode changes to manual or swipe.</td><td valign="top"><code>function ClearentEntryModeChange(mode){ console.log("User set SDK to mode: ", mode); }</code></td><td valign="top">You can call the function if it is defined on the host page.</td></tr><tr><td valign="top"><code>ClearentOnPaymentTypeChange(paymentType)</code></td><td valign="top">Call the function to receive a raw server response or a JSON-formatted response data object if <code>getPaymentToken</code> returns successfully.</td><td valign="top"><code>function ClearentOnPaymentTypeChange(paymentType) { console.log("Payment Type was changed to: " + paymentType); }</code></td><td valign="top">You can call the function if it is defined on the host page.</td></tr><tr><td valign="top"><code>ClearentTokenError(responseRaw, responseJSON)</code></td><td valign="top">Call the function to receive a raw server response or a JSON-formatted response data object if <code>getPaymentToken</code> returns an error.</td><td valign="top"><code>function ClearentTokenError(responseRaw, responseJSON){ console.log("ClearentTokenError"); console.log(responseRaw); console.log(responseJSON); }</code></td><td valign="top">You can call the function if it is defined on the host page.</td></tr><tr><td valign="top"><code>ClearentTokenSuccess(responseRaw, responseJSON)</code></td><td valign="top">Call the function to receive a raw server response or a JSON-formatted response data object if <code>getPaymentToken</code> is successful.</td><td valign="top"><code>function ClearentTokenSuccess(responseRaw,responseJSON){ console.log("ClearentTokenSuccess"); console.log(responseRaw); console.log(responseJSON); // now you can send the token to your server // to complete the transaction via mobile-gateway }</code></td><td valign="top">You can call the function if it is defined on the host page.</td></tr><tr><td valign="top"><code>ClearentValidation(messages)</code></td><td valign="top">Call the function to validate the payment form fields information that returns the validation message with a JavaScript array.</td><td valign="top"><code>function ClearentValidation(messages) { console.log("ClearentValidation"); console.log(messages); // you can handle these messages and display in your own form // empty messages array indicates no validation errors }</code></td><td valign="top">When the payment fields have valid information, a JavaScript array in the validation message will be empty.</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.xplorpay.com/guides/javascript/configure-payment-page/methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
