Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Realistically your application will generate the JWT when the page that includes Songbird.js is rendered. This page will most likely include JavaScript to allow the consumer to dynamically change order details without requiring a full page load. This means that the order details provided when you loaded the page within the JWT can be stale and out dated when you start the transaction with Songbird.js. Cardinal Cruise allows you to pass an updated or additional order data through Songbird.js to make sure the transactional data is always the latest. Cardinal will merge these objects server side automatically, always taking the browser data as the most recent and overrides the JWT order data.

Table of Contents


Info

Object merging is done automatically by the Centinel API. This feature will always occur with all requests and cannot be disabled or behavior changed.


Examples

Below are examples of how the merging can affect your objects in different ways.

Info

Remember that all merging types are active at once. The examples are broken out to help explain the different ways things are merged.

Additive Merge

Additive merging will take unique fields from each object to create a fuller more complete object

Code Block
languagejs
titleJWT Order Object
{
  "OrderDetails":{
	"Amount":1500,
	"CurrencyCode": "840"
  }
}


Code Block
languagejs
titleBrowser Order Object
{
  "OrderDetails":{
	"OrderDescription":"My new order"
  }
}


Code Block
languagejs
titleMerged Object
{
  "OrderDetails":{
	"Amount":1500,
	"CurrencyCode": "840",
    "OrderDescription":"My new order"
  }
}

Update Merging

Update merging will overwrite stale fields from the JWT order object with the more recent browser object

Code Block
languagejs
titleJWT Order Object
{
  "OrderDetails":{
	"Amount":1500
  }
}


Code Block
languagejs
titleBrowser Order Object
{
  "OrderDetails":{
	"Amount":2500
  }
}


Code Block
languagejs
titleMerged Object
{
  "OrderDetails":{
	"Amount":2500
  }
}

Real World Example

You may not have all the data when you create the JWT, so most likely your JWT order object will be a bit more sparse than the browser object.

Code Block
languagejs
titleJWT Order Object
{
  "OrderDetails":{
	"Amount":2500,
	"CurrencyCode": "840",
	"OrderNumber":"sa4lj2kds34SAIu97sde12d3"
  },
  "Cart":[
	{
	  "Name":"Blue Jeans",
	  "Quantity":1
	}
  ],
  "Consumer":{
    "ShippingAddress":{
      "FirstName": "John",
      "LastName":"Smith",
	  "Address1":"8100 Tyler Blvd.",
	  "City": "Mentor",
	  "State":"Ohio",
	  "PostalCode":"44060"
	}
  }
}


Code Block
languagejs
titleBrowser Order Object
{
  "Consumer":{
    "Account":{
	  "AccountNumber": 4000...0002,
	  "ExpirationMonth": 01,
	  "ExpirationYear": 2020,
	  "NameOnCard":"John Smith"
	},
    "BillingAddress":{
      "FirstName": "John",
      "LastName":"Smith",
	  "Address1":"8100 Tyler Blvd.",
	  "City": "Mentor",
	  "State":"Ohio",
	  "PostalCode":"44060"
	},
	"ShippingAddress":{
      "FirstName": "John",
      "LastName":"Smith",
	  "Address1":"123 Main Street",
	  "City": "Cleveland",
	  "State":"Ohio",
	  "PostalCode":"44091"
	}
  }
}


Code Block
languagejs
titleMerged Object
{
  "OrderDetails":{
	"Amount":2500,
	"CurrencyCode": "840",
	"OrderNumber":"sa4lj2kds34SAIu97sde12d3"
  },
  "Cart":[
	{
	  "Name":"Blue Jeans",
	  "Quantity":1
	}
  ],
  "Consumer":{
    "Account":{
	  "AccountNumber": 4000...0002,
	  "ExpirationMonth": 01,
	  "ExpirationYear": 2020,
	  "NameOnCard":"John Smith"
	},
    "BillingAddress":{
      "FirstName": "John",
      "LastName":"Smith",
	  "Address1":"8100 Tyler Blvd.",
	  "City": "Mentor",
	  "State":"Ohio",
	  "PostalCode":"44060"
	},
	"ShippingAddress":{
      "FirstName": "John",
      "LastName":"Smith",
	  "Address1":"123 Main Street",
	  "City": "Cleveland",
	  "State":"Ohio",
	  "PostalCode":"44091"
	}
  }
}