/*
 * Create the HTML tags objects.
 */
$content_div = new HTMLTags_Div();
$content_div->set_attribute_str('id', 'content');
/*
 * The title of the page.
 */
$content_div->append_tag_to_content(new HTMLTags_Heading(2, 'Payment Confirmed'));
if (isset($_GET['crypt']) && isset($_GET['session'])) {
    $strCrypt = $_GET['crypt'];
    $session_id = $_GET['session'];
    // Now decode the Crypt field and extract the results
    $strDecoded = Shop_ProtxPayments::simpleXor(Shop_ProtxPayments::Base64Decode($strCrypt), $strEncryptionPassword);
    //                print_r($strDecoded);exit;
    $values = Shop_ProtxPayments::getToken($strDecoded);
    // Split out the useful information into variables we can use
    $strStatus = $values['Status'];
    $strStatusDetail = $values['StatusDetail'];
    $strVendorTxCode = $values["VendorTxCode"];
    $strVPSTxId = $values["VPSTxId"];
    $strTxAuthNo = $values["TxAuthNo"];
    $strAmount = $values["Amount"];
    $strAVSCV2 = $values["AVSCV2"];
    $strAddressResult = $values["AddressResult"];
    $strPostCodeResult = $values["PostCodeResult"];
    $strCV2Result = $values["CV2Result"];
    $strGiftAid = $values["GiftAid"];
    $str3DSecureStatus = $values["3DSecureStatus"];
    $strCAVV = $values["CAVV"];
    $transactions_table = $database->get_table('hpi_protx_payments_transactions');
$strPost = $strPost . "&DeliveryAddress=" . $address->get_street_address() . " " . $address->get_locality();
$strPost = $strPost . "&DeliveryPostCode=" . $address->get_postal_code();
// Optionally add the contact numbers, if they are present
$strPost = $strPost . "&ContactNumber=" . $telephone_number->get_telephone_number();
$strPost = $strPost . "&Basket=" . $str_basket;
// As created above
/* Allow fine control over AVS/CV2 checks and rules by changing this value. 0 is Default 
** It can be changed dynamically, per transaction, if you wish.  See the VSP Server Protocol document */
if ($strTransactionType !== "AUTHENTICATE") {
    $strPost = $strPost . "&ApplyAVSCV2=0";
}
/* Allow fine control over 3D-Secure checks and rules by changing this value. 0 is Default 
** It can be changed dynamically, per transaction, if you wish.  See the VSP Server Protocol document */
$strPost = $strPost . "&Apply3DSecure=0";
// Encrypt the plaintext string for inclusion in the hidden field
$strCrypt = Shop_ProtxPayments::base64Encode(Shop_ProtxPayments::SimpleXor($strPost, $strEncryptionPassword));
#################################################################################
## END OF CRYPT BUILDER
#################################################################################
$protx_form_div = new HTMLTags_Div();
$protx_form_div->set_attribute_str('id', 'paypal_form_div');
$protx_form = new HTMLTags_Form();
$protx_form_action = new HTMLTags_URL();
//$protx_form_action->set_file('https://ukvps.protx.com/vspgateway/service/vspform-register.vsp'); # The real thing
//$protx_form_action->set_file('https://ukvpstest.protx.com/vspgateway/service/vspform-register.vsp'); # The sandbox
$protx_form_action->set_file($strPurchaseURL);
# The URL set above
$protx_form->set_action($protx_form_action);
$protx_form->set_attribute_str('method', 'POST');
$protx_form->add_hidden_input('VPSProtocol', '2.22');
$protx_form->add_hidden_input('TxType', $strTransactionType);