The fatzebra.js Javascript SDK will emit various events that your client-side Javascript code can subscribe to.

An event may be emitted along with a data payload, which is encapsulated into a CustomEvent object and can be retrieved via the detail property of the event.

List of fatzebra.js events

Successful Event Data Format

Attribute

Type

Description

message

string

message

data

object

data

{
  message: "xxx",
  data: {
   ... 
  }
}

Error Event Data Format

Attribute

Type

Description

errors

array of string

error messages

data

object

This could be null if no data is available.

{
  errors: [
    "xxx",
    ...
  ],
  data: {
   //  
  }
}

Subscribing to an event

const fz = new FatZebra({
  username: "MerchantXYZ"
});

// Handle errors related to general errors. For example, client-side validations.
fz.on('fz.validation.error', function(event) {
  // ...
});

// Handle errors related to payment processing. HPP only.
fz.on('fz.payment.error', function(event) {
  // prompt error to customer
  console.log('payment errors: ' + JSON.stringify(event.detail.errors));
});

// Handle successful payment processing. HPP only.
fz.on('fz.payment.success', function(event) {
  console.log('payment data: ' + JSON.stringify(event.detail.data));
});