Exemple #1
0
                // Sesssion refreshed with valid tokens
                header("Location: " . $client->getCurrentURI(array(), array('code', 'login', 'error', 'logout', 'order_id', 'spid_page')));
                exit;
            } 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>';
}
?>
Exemple #2
0
		<h1 id="exampleUrlLink">Show Example URL's</h1>
		<ul id="exampleUrls">
			<li><a href="<?php 
    echo $client->getPurchaseURI(array('redirect_uri' => $client->getCurrentURI(array(), array('logout'))));
    ?>
">Purchase Any Product</a></li>
			<li><a href="<?php 
    echo $client->getPurchaseURI(array('product_id' => '1', 'redirect_uri' => $client->getCurrentURI(array(), array('logout'))));
    ?>
">Purchase Product 1</a></li>
			<li><a href="<?php 
    echo $client->getPurchaseURI(array('product_id' => '1', 'display' => 'popup', 'redirect_uri' => $client->getCurrentURI(array(), array('logout'))));
    ?>
&keepThis=true&TB_iframe=true&height=380&width=300" class="thickbox">1 Click Purchase</a></li>
			<li><a href="<?php 
    echo $client->getAccountURI();
    ?>
">Account page</a></li>
			<li><a href="<?php 
    echo $client->getPurchaseHistoryURI();
    ?>
">Purchase history page</a></li>
		</ul>
	</div>	
</div>
<div id="output">
	<img id="loader" src="images/loader-small.gif" alt="loading.." />

	<pre class="prettyprint">
	</pre>
</div>