dimanche 10 janvier 2016

PHP script is not checking nested if else loop

I am trying to test online payment gateway connection but following php code is directly redirecting to paymnet.failure page without checking nested if else loop can you please help me

$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();
}

Aucun commentaire:

Enregistrer un commentaire