Breeze Docs

Cart Signature Generation

When you are using Custom integration, you will need to sign a stringified cart & pass it to process method of the SDK. This is to ensure that the cart data has not been tampered with.

In order to achieve this you need to do the following:

Perquisite

In order to begin generating the signature, you need to have the following:

RSA Private Public Key Pair

Use the following commands to generate private public key pair.

# Generate private key
openssl genrsa -out private-key.pem 2048

# Generate public key against the private key generated above
openssl rsa -in private-key.pem -pubout -out public-key.pem

Public Key Configuration on Breeze

Connect with the Breeze team to share the public key generated above. This key will be used to verify the signature generated by you.

Once the above perquisites are met, you can proceed with the following steps to generate the signature.

Signature Generation

Step 1: Convert your Cart to Breeze Cart Object

Breeze systems expect the cart to be in a specific format. You need to convert your cart to the Breeze cart object.

Following is the structure of the Breeze Cart Object:

Breeze Cart Object
Params Type Mandatory Description
id String Yes Identifier you your cart
initialPrice Number Yes The initial price of the cart
totalPrice Number Yes The total price of the cart
totalDiscount Number Yes The total discount applied on the cart
weight Number No The total weight of the cart
itemCount Number Yes The total number of items in the cart
currency Currency Yes The currency of the cart
items Array<BreezeCartItem> Yes The array of items in the cart
Breeze Cart Item
Params Type Mandatory Description
id String Yes The ID of the item.
title String Yes The title of the item.
variantTitle String No The variant title of the item.
variantId String No The variant ID of the item.
image String No The image URL of the item.
weight Number No The weight of the item.
quantity Number Yes The quantity of the item.
discount Number Yes The discount applied on the item.
initialPrice Number Yes The initial price of the item.
finalPrice Number Yes The final price of the item.

Step 2: Stringify Breeze Cart Object

Convert the Breeze Cart Object created from Step 1 to a stringified JSON object. You can use your language specific JSON stringify method to achieve this.

Example for Javascript/Typescript:

const breezeCartString = JSON.stringify(breezeCartObject);

Step 3: Sign the Stringified Cart

Use the private key generated in the perquisite to sign the stringified cart.

You can refer this link for code snippets in various languages to sign the stringified cart.

Note: The signature generated should be passed to the process method of the SDK along with the stringified cart.