Commercetools Checkout Typescript SDK
Usage examples
Browser environment
<script src="https://unpkg.com/@commercetools/checkout-borwser-sdk@latest/browser/commercetools-sdk-client-v2.umd.js"></script>
<script>
(function(w, d, s){
if (w.ctc) {return;}
var js, fjs = d.getElementsByTagName(s)[0];
var q = [];
w.ctc = w.ctc || function() { q.push(arguments); }
w.ctc.q = q;
js = d.createElement(s);
js.type = 'text/javascript';
js.async = true;
js.src = 'https://cdn.checkoutanywhere.io/sdk.js';
fjs.parentNode.insertBefore(js, fjs);
}(window, document, 'script'));
ctc('init', {
checkoutConfig: {
sellerId: '{sellerId}',
applicationId: '{applicationId}',
callbackUrl: '{callbackUrl}',
cartId: '{cartId}',
accessToken: '{accessToken}',
locale: '{locale}'
}
});
</script>
Node environment
import sdk from '@commercetools/checkout-browser-sdk';
sdk.init({
logInfo: true,
logWarn: true,
logError: true,
onInfo: m => console.log('[Info]', m),
});
sdk.checkout({
sellerId: 'some-seller-id',
applicationId: 'some-application-id',
callbackUrl: window.location.origin + "/confirmation",
cartId: 'some-id',
accessToken: 'some-access-token',
locale: 'en'
});