> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slm.m1amdocs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Setting up HOA

This section shows how to set up basic HOA.

1. Include the SOAP Client in your page.

   ```

   <?php 
   require_once("Vindicia/Soap/Vindicia.php");
   ?>
   ```

2. Start a new WebSession object.

   ```

    <?php
    define("HOA_RETURN_URL", "https://store.merchant.com/websession/success.php");
    define("HOA_CANCEL_URL", "https://store.merchant.com/websession/error.php");
    $websession = new WebSession();
    $websession->setReturnURL(HOA_RETURN_URL);
    $websession->setErrorURL(HOA_CANCEL_URL);
    ?>
   ```

3. Load the WebSession with private values.

   ```

    <?php
    $privateVals = array();
    $nvp0 = new NameValuePair();
    $nvp0->setName('vin_Account_merchantAccountId');
    $nvp0->setValue($account_id); // use the account we just created on a previous page
    $privateVals[] = $nvp0;
    
    $nvp1 = new NameValuePair();
    $nvp1->setName('vin_AutoBill_merchantAutoBillId');
    $nvp1->setValue($autobill_id);
    $privateVals[] = $nvp1;
    
    $nvp2 = new NameValuePair();
    $nvp2->setName('vin_AutoBill_items_0_Product_merchantProductId');
    $nvp2->setValue($product_id);
    $privateVals[] = $nvp2;
    
    $nvp3 = new NameValuePair();
    $nvp3->setName('vin_BillingPlan_merchantBillingPlanId');
    $nvp3->setValue($billing_plan);
    $privateVals[] = $nvp3;
    
    $websession->setPrivateFormValues($privateVals);
    ?>
    
   ```

4. Load the WebSession with method parameter values.

   ```

    <?php
    $websession->setMethod('AutoBill_Update');
    
    $nvp12 = new NameValuePair();
    $nvp12->setName('AutoBill_Update_duplicateBehavior');
    $nvp12->setValue('Fail');
    
    $nvp13 = new NameValuePair();
    $nvp13->setName('AutoBill_Update_validateForFuturePayment');
    $nvp13->setValue('1');
    
    $nvp14 = new NameValuePair();
    $nvp14->setName('AutoBill_Update_minChargebackProbability');
    $nvp14->setValue('99');
    
    $nvp15 = new NameValuePair();
    $nvp15->setName('AutoBill_Update_ignoreAvsPolicy');
    $nvp15->setValue('true');
    
    $nvp16 = new NameValuePair();
    $nvp16->setName('AutoBill_Update_ignoreCvnPolicy');
    $nvp16->setValue('true');
    
    $nvp17 = new NameValuePair();
    $nvp17->setName('AutoBill_Update_campaignCode');
    $nvp17->setValue($coupon);
    
    $websession->setMethodParamValues(array($nvp12,$nvp13,$nvp14,$nvp14,$nvp15));
    ?>
   ```

   **Note:** Note that `nvp16` and `nvp17` are purposely not passed into WebSession. They are provided as additional examples.

5. Initialize the WebSession to generate a session ID.

   ```

    <?php
    $srd = ""; # Soap 13.0 and higher has SRD
    $rc = $websession->initialize($srd);
    $response_object = $rc['data'];
    $return_code = $rc['returnCode'];
    $return_object = $response_object->session;
    $session_id = $return_object->VID; # Web Session ID for embedding in html form
    ?>
   ```

6. Create a form with some hidden fields.

   Two hidden fields are required:

   * `vin_WebSession_version` (SOAP version)
   * `vin_WebSession_vid` (Session Id)

     **Note:** Note that SOAP versions 13 and higher use Sparse Response Descriptions (SRD).

     ```

      <h3>Credit/Debit Card Information</h3>
      
      <form id="mainForm" name="mainForm" class="form-horizontal" 
      action="https://secure.vindicia.com/vws" method="post">
       <input type="hidden" name="vin_WebSession_version" value="21.0" />
       <input type="hidden" name="vin_WebSession_vid" value="<?php print $session_id ?>" />
       <input type="hidden" name="vin_PaymentMethod_type" value="CreditCard" />
     ```

7. Create some input fields that do not require protection (Hosted Fields).

   ```

     <input type="text" class="form-control" id="vin_PaymentMethod_accountHolderName" 
     name="vin_PaymentMethod_accountHolderName" 
     placeholder="Enter Cardholder Name" value=""/>
   ```

8. Create some input fields that do require protection (Hosted Fields).

   ```

    <div id="vin_PaymentMethod_creditCard_account"></div>
    <div id="vin_PaymentMethod_creditCard_expirationDate"></div>
    <div id="vin_PaymentMethod_nameValues_cvn"></div>
   ```

9. Call vindicia.setup to establish the protected fields (Hosted Fields) inside iframes.

   ```

    <script type="text/javascript">
     vindicia.setup(options);
    </script>
   ```

Proceed to [Setting Up Hosted Fields](Setting_Up_Hosted_Fields#).

**Parent topic:**[Implementing HOA with Hosted Fields](../topics/Implementing_HOA_with_Ho)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.