Skip to content

Instantly share code, notes, and snippets.

@ndv
Created July 18, 2012 12:50
Show Gist options
  • Save ndv/3136037 to your computer and use it in GitHub Desktop.
Save ndv/3136037 to your computer and use it in GitHub Desktop.
Checkout Widget API: Initialization
<?php
define('CHECKOUT_WIDGET_OWNERID', 'TEST-123');
define('CHECKOUT_WIDGET_KEY', 'secret');
$timestamp = time();
$signature = hash_hmac( "sha1", CHECKOUT_WIDGET_OWNERID." ".$timestamp, CHECKOUT_WIDGET_KEY);
?>
<script src="https://checkout.ecwid.com/controlpanel-api.js" type="text/javascript" charset="UTF-8"></script>
<script>
EcwidCheckout.init({
ownerId: '<?php echo CHECKOUT_WIDGET_OWNERID;?>',
timestamp: '<?php echo $timestamp;?>',
hmacsha1: '<?php echo $signature;?>',
loginUrl: 'http://my.site.com/login.php'
});
EcwidCheckout.OnAPILoaded.add(function() {
// Checkout Widget API is available, do something
window.EcwidCheckout.setConfig({
currency: {precision:2,roundScale:100,prefix:'$',suffix:'',code:'USD'},
weightUnit: 'POUND',
storeName: "Test store",
companyEmail: "[email protected]",
storeUrl: "http://www.example.com"
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment