Cart cancellation

Steps and examples to send cancellations

Native Javascript cancellation

Files location and description

- luckyclient.min.js : the JS library
javascript/lc_cancel_sample.html : an example of use

Integration steps

 1. Install library

Insert the JavaScript library at the top of the cancellation confirmation page, using the specific URL provided by Lucky Cart :

<!-- Include library using the URL provided by Lucky Cart -->
<script src="/path/to/luckyclient.min.js" type="text/javascript"> </script> 

2. Initialize library and send cancellation

On the same cancellation confirmation page, use the cancel() method of Luckycart class :

<script type="text/javascript”>
  // Create a Lucky Cart object with your key and secret
  var client = new Luckycart('key', 'Secret');

  // Cancels the specified cart
  client.init(function(){
    client.cancel(cart.getId(), function(res){
      // and do something with the response
      document.body.innerHTML+='<br/>'+'id='+res.id;
      document.body.innerHTML+='<br/>'+'tickets='+res.tickets;
    });
  });
</script>

3. Use response, if needed

The returned res object can be used and contains the following information :

- res.id : specified unique cart Id
- res.tickets : number of cancelled tickets