Created
July 18, 2012 12:50
-
-
Save ndv/3136037 to your computer and use it in GitHub Desktop.
Checkout Widget API: Initialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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