如果是else循环,PHP脚本不会检查嵌套

时间:2016-01-11 00:37:24

标签: php function if-statement header

我正在尝试测试在线支付网关连接,但是以下php代码是直接重定向到paymnet.failure页面而不检查嵌套if else循环可以请你帮助我

$alive = $sp->TestConnection();
if ($alive)
{

    $sp->Cc             = trim($_POST['card_number']);
    $sp->ExpiryDate     = (int)$_POST['card_expiry_month'] . '/' . (int)$_POST['card_expiry_year'];
    $sp->ChargeAmount   = $payment_amount;
    $sp->ChargeCurrency = 'AUD';
    $sp->Cvv            = trim($_POST['card_cvn']);
    $sp->OrderId        = 'HO-Payment-' . $payment_id;

    // Check if Transaction was Approved
    if ($sp->Valid()) 
     { // Is the above data valid?
        $response = $sp->Process();
    if ($response != SECUREPAY_STATUS_APPROVED) 
    {
            echo "Sorry, your payment was declined. Please contact your card issuer.";
            $_SESSION['error_msg'] = "Sorry, your payment was declined. Please contact your card issuer.\nError code: $response\n";
        header('location: /payment-failure');
            exit();
    }
    } else 
    {
        $_SESSION['error_msg'] = 'An Unknown Error Occurred and Payment Failed. Please Try Again Later.';
        header('location: /payment-failure');
        exit();
    }

} else {
    $_SESSION['error_msg'] = 'An Unknown Error Occurred and Payment Failed. Please Try Again Later.';
    header(location: /payment-failure);
    exit();
}

0 个答案:

没有答案