Client-Side Setup {#micro-getting-started-pay-card-cs-setup}
============================================================

You can integrate `Microform Integration` with your native payment acceptance web page or mobile application.

Web Page {#setting-up-client-side-v2-web-card-task1}
----------------------------------------------------

Initiate and embed `Microform Integration` into your payment acceptance web page.

1. Decode the JWT from the `/microform/v2/sessions` response to get the capture context.

2. Use the clientLibrary and clientLibraryIntegrity values that are returned in the JWT from `/microform/v2/sessions` response to obtain the `Microform Integration` JavaScript library URL and integrity value that you use to create your script tags.

   > IMPORTANT You must use these values for every transaction. These values can be unique for each transaction.
   > IMPORTANT
   > Do not hard code these values, because doing so can result in client-side ` Microform Integration ` errors. If you do not hard code these values for all transactions, you can load a JavaScript library that is incompatible with the version you requested in the ` /sessions ` request.  
   > **Example `/sessions` Response:**

   ```
   "data":{ "clientLibrary":"[EXTRACT clientLibrary VALUE from here]", "clientLibraryIntegrity": "[EXTRACT clientLibraryIntegrity VALUE from here]" }
   ```

   **Example Script Tags**

   ```
   &lt;script src="[INSERT clientLibrary VALUE HERE]" integrity=”[INSERT clientLibraryIntegrity VALUE HERE]” crossorigin=”anonymous”&gt; &lt;/script&gt; 
   ```

   **Example Code for Loading the Script Dynamically Following JWT Extraction Tags**

   ```
   // values read from capture context
   const clientLibrary = " ";
   const clientLibraryIntegrity = " ";
   // create script tag
   const script = document.createElement("script");
   script.src = clientLibrary;
   script.type = "text/javascript";
   script.async = true;
   script.integrity = clientLibraryIntegrity;
   script.crossOrigin = "anonymous";
   // run setup code after script has loaded successfully
   script.onload = function () {
     // SETUP
   };
   // insert to document
   document.head.appendChild(script);
   ```
3. Create the HTML placeholder objects to attach to the microforms.  
   `Microform Integration` attaches the microform fields to containers within your HTML. Within your HTML checkout, replace the payment card and CVN tag with a simple container. `Microform Integration` uses the container to render an iframe for secured credit card input. This example contains simple `div` tags to define where to place the PAN and CVN fields within the payment acceptance page: `&lt;div id="number-container" class="form-control"&gt;&lt;/div&gt;`.  
   **Example: Accept Card Information Checkout Form**

   ```
   &lt;h1&gt;Checkout Page&lt;/h1&gt;
   &lt;div id="errors-output" role="alert"&gt;&lt;/div&gt;
   &lt;form action="/token" id="my-sample-form" method="post"&gt;
       &lt;div class="form-group"&gt;
           &lt;label for="cardholderName"&gt;Name&lt;/label&gt;
           &lt;input id="cardholderName" class="form-control" name="cardholderName" placeholder="Name on the card"&gt;
           &lt;label id="cardNumber-label"&gt;Card Number&lt;/label&gt;
           &lt;div id="number-container" class="form-control"&gt;&lt;/div&gt;
           &lt;label for="securityCode-container"&gt;Security Code&lt;/label&gt;
           &lt;div id="securityCode-container" class="form-control"&gt;&lt;/div&gt;
       &lt;/div&gt;

       &lt;div class="form-row"&gt;
           &lt;div class="form-group col-md-6"&gt;
               &lt;label for="expMonth"&gt;Expiry month&lt;/label&gt;
               &lt;select id="expMonth" class="form-control"&gt;
                   &lt;option&gt;01&lt;/option&gt;
                   &lt;option&gt;02&lt;/option&gt;
                   &lt;option&gt;03&lt;/option&gt;
                   &lt;option&gt;04&lt;/option&gt;
                   &lt;option&gt;05&lt;/option&gt;
                   &lt;option&gt;06&lt;/option&gt;
                   &lt;option&gt;07&lt;/option&gt;
                   &lt;option&gt;08&lt;/option&gt;
                   &lt;option&gt;09&lt;/option&gt;
                   &lt;option&gt;10&lt;/option&gt;
                   &lt;option&gt;11&lt;/option&gt;
                   &lt;option&gt;12&lt;/option&gt;
               &lt;/select&gt;
           &lt;/div&gt;
           &lt;div class="form-group col-md-6"&gt;
               &lt;label for="expYear"&gt;Expiry year&lt;/label&gt;
               &lt;select id="expYear" class="form-control"&gt;
                   &lt;option&gt;2021&lt;/option&gt;
                   &lt;option&gt;2022&lt;/option&gt;
                   &lt;option&gt;2023&lt;/option&gt;
               &lt;/select&gt;
           &lt;/div&gt;
       &lt;/div&gt;

       &lt;button type="button" id="pay-button" class="btn btn-primary"&gt;Pay&lt;/button&gt;
       &lt;input type="hidden" id="flexresponse" name="flexresponse"&gt;
   &lt;/form&gt;
   ```
4. Invoke the Flex SDK by passing the capture context that was generated in the previous step to the microform object.  
   `const flex = new Flex(captureContext);`

5. Initiate the microform object with styling to match your web page.  
   After you create a new Flex object, you can begin creating your Microform. You will pass your baseline styles and ensure that the button matches your merchant page:  
   `const microform = flex.microform("card", { styles: myStyles });`

6. Create and attach the microform fields to the HTML objects through the Microform Integration JavaScript library.

   ```
   const number = microform.createField('number', { placeholder: 'Enter card number' });
   const securityCode = microform.createField('securityCode', { placeholder: '•••' });
               number.load('#number-container');
               securityCode.load('#securityCode-container');
   ```
7. Create a function for the customer to submit their payment information, and invoke the tokenization request to `Microform Integration` for the transient token.
   {#setting-up-client-side-v2-web-card-task1_setting-up-client-side-v2-steps}

Mobile Application {#setting-up-client-side-v2-web-mobile-task2}
----------------------------------------------------------------

To initiate and embed `Microform Integration` into a native payment acceptance mobile application, follow the steps for web page set up, and ensure that these additional requirements are met:

* The card information acceptance fields of PAN and CVV must be hosted on a web page.
* The `eCheck` information acceptance fields of routing number, account number, and confirmed account number must be hosted on a web page.
* The native application must load the hosted card entry form web page in a web view.

