<?php
require_once 'function.sagepay.php';

require_once 'payment-string.php';

if ($arrResponse['NextURL'] != '') {
    ?>

    <div class="sagepayServerForm">

        <h2>Order Payment <?php if ($strConnectTo == "TEST") { echo " - Test Server"; } ?></h2>

		<?php
        if ($strConnectTo == "TEST") {
            ?>
            <div class="alertBlue">
                Test Cards: <br/>
                4929000000006 / CVC: 123 <br/>
            </div>
            <?php
        }
        if(SAGEPAY_TOKEN == true && !empty($member->id) )
        {
            if($_REQUEST["save_card"]!="no"){
                if($member->id > 0 && $member->sagepay_token!=""){
                    ?>
                    <a href="?action=reset_token#savecard" class="right editDetails editcard">Edit</a>
                	<h3>Saved Card details:</h3>
                	<p>
                	Card type: <?=$member->sagepay_card; ?>
                	</p><p>
                	Last 4 numbers: xxxx-xxxx-xxxx-<?=$member->sagepay_last4; ?>
                	</p>
                    <?php
                }else{
                    ?>
                    <a href="/shop/checkout/basket_overview.php?save_card=no#savecard"><i class="fa fa-check-square-o">Don't</i> save card details for future purchases</a>
                <?php
                }
            }else{
                ?>
                <a href="/shop/checkout/basket_overview.php#savecard"> <i class="fa fa-square-o"></i> Save card details for future purchases</a>
                <?php
            }
        } ?>

        <iframe src="<?= $arrResponse['NextURL']; ?>" class="sagePayServerIframe"></iframe>

    </div> <!--End of main-content -->

    <?php
} else {
    ?>

    <div class="sagepayServerForm">

        <h2>Oops there was a problem</h2>

        <p><?= format_page(substr($arrResponse['StatusDetail'], 1 + strpos($arrResponse['StatusDetail'], ": "))); ?></p>

        <p>Please double check your details and <a href="/shop/checkout/basket.php">try again</a>.</p>

    </div>
    <?php
}
