Ejemplo n.º 1
0
            } catch (Exception $e2) {
                /* falls back to $e message bellow */
            }
        }
        if ($e->getCode() == 400) {
            header("Location: " . $client->getLoginURI(array('redirect_uri' => $client->getCurrentURI(array(), array('logout', 'error', 'code', 'order_id', 'spid_page')))));
            exit;
        }
        // API exception, show message, remove session as it is probably not usable
        unset($_SESSION['sdk']);
        echo '<h3 id="error" style="color:red">' . $e->getCode() . ' : ' . $e->getMessage() . '</h3>';
    }
    echo '<p><a id="login-link" href="' . $client->getAccountURI(array('redirect_uri' => $client->getCurrentURI(array(), array('logout', 'error', 'code', 'order_id', 'spid_page')))) . '">My Account</a></p>';
    // Show a logout link
    echo '<p><a id="login-link" href="' . $client->getLogoutURI(array('redirect_uri' => $client->getCurrentURI(array('logout' => 1), array('error', 'code', 'order_id', 'spid_page')))) . '">Logout</a></p>';
    echo '<p><a id="login-link" href="' . $client->getPurchaseURI(array('redirect_uri' => $client->getCurrentURI(array(), array('logout', 'error', 'code', 'order_id', 'spid_page')), 'cancel_redirect_uri' => $client->getCurrentURI(array('cancel' => 1), array('logout', 'error', 'code', 'order_id', 'spid_page')))) . '">Buy something</a> (standard checkout flow)</p>';
    echo '<p><a id="login-link" href="' . $client->getPurchaseURI(array('campaign_id' => 1, 'redirect_uri' => $client->getCurrentURI(array('cameback' => 2), array('logout', 'error', 'code', 'order_id', 'spid_page')), 'cancel_redirect_uri' => $client->getCurrentURI(array('cancel' => 1), array('logout', 'error', 'code', 'order_id', 'spid_page')))) . '">Campaign Flow</a> (checkout flow with campaign specified</p>';
} else {
    // No session, user must log in
    echo '<h3 id="message">Please log in</h3>';
    // Show a login link
    echo '<p><a id="login-link" href="' . $client->getLoginURI(array('redirect_uri' => $client->getCurrentURI(array('place' => 'oslo'), array('logout', 'error', 'code', 'default', 'cancel', 'order_id', 'spid_page')), 'cancel_redirect_uri' => $client->getCurrentURI(array('cancel' => 1), array('logout', 'error', 'code', 'default', 'cancel', 'order_id', 'spid_page')))) . '">Login</a> (standard auth flow)</p>';
    echo '<h5>or</h5>';
    echo '<p><a id="signup-flow-link" href="' . $client->getSignupURI(array('redirect_uri' => $client->getCurrentURI(array(), array('logout', 'error', 'code', 'order_id', 'spid_page')), 'cancel_redirect_uri' => "http://google.com")) . '">Signup Flow</a> (standard auth flow with signup parameter</p>';
    echo '<h5>or</h5>';
    echo '<p><a id="checkout-link" href="' . $client->getPurchaseURI(array('redirect_uri' => $client->getCurrentURI(array(), array('logout', 'error', 'code', 'order_id', 'spid_page')), 'cancel_uri' => $client->getCurrentURI(array('cancel' => 1), array('logout', 'error', 'code', 'default', 'cancel', 'order_id', 'spid_page')))) . '">Buy</a> (standard checkout flow)</p>';
}
?>
</body>
</html>