import HenrySDK from '@henrylabs/sdk';
const client = new HenrySDK({
apiKey: process.env['HENRY_SDK_API_KEY'], // This is the default and can be omitted
});
const response = await client.cart.fetch('crt_sa2aEsCz9PRM', {
buyer: {
name: { firstName: 'John', lastName: 'Doe' },
email: 'john@example.com',
phone: '+15551234567',
shippingAddress: {
name: { firstName: 'John', lastName: 'Doe' },
line1: '123 Main St',
city: 'New York',
province: 'NY',
postalCode: '10001',
countryCode: 'US',
},
},
});
console.log(response.data);{
"success": true,
"status": "<string>",
"message": "<string>",
"data": {
"cartId": "<string>",
"checkoutUrl": "<string>",
"data": {
"items": [
{
"link": "https://www.nike.com/u/custom-nike-ja-3-by-you-10002205",
"quantity": 1,
"selectedOptions": [
"regular",
"black",
"10-w"
],
"selectedShipping": {
"value": "standard"
},
"coupons": [
"SUMMER26",
"SAVE10"
],
"metadata": {
"creatorSource": "Frank Herbert"
}
}
],
"settings": {
"options": {
"allowPartialPurchase": true,
"collectBuyerEmail": "required",
"collectBuyerAddress": "optional",
"collectBuyerPhone": "off"
},
"commissionFeeFixed": {
"value": 1.99,
"currency": "USD"
},
"commissionFeePercent": 10,
"events": [
{
"type": "order",
"data": [
{
"type": "<string>",
"points": 123
}
],
"conditional": {
"type": "<string>",
"operator": "equals",
"value": "<string>"
}
}
]
},
"tags": {}
},
"metadata": {}
}
}Fetch a single cart by ID and optionally prefill buyer details in the returned checkout URL.
import HenrySDK from '@henrylabs/sdk';
const client = new HenrySDK({
apiKey: process.env['HENRY_SDK_API_KEY'], // This is the default and can be omitted
});
const response = await client.cart.fetch('crt_sa2aEsCz9PRM', {
buyer: {
name: { firstName: 'John', lastName: 'Doe' },
email: 'john@example.com',
phone: '+15551234567',
shippingAddress: {
name: { firstName: 'John', lastName: 'Doe' },
line1: '123 Main St',
city: 'New York',
province: 'NY',
postalCode: '10001',
countryCode: 'US',
},
},
});
console.log(response.data);{
"success": true,
"status": "<string>",
"message": "<string>",
"data": {
"cartId": "<string>",
"checkoutUrl": "<string>",
"data": {
"items": [
{
"link": "https://www.nike.com/u/custom-nike-ja-3-by-you-10002205",
"quantity": 1,
"selectedOptions": [
"regular",
"black",
"10-w"
],
"selectedShipping": {
"value": "standard"
},
"coupons": [
"SUMMER26",
"SAVE10"
],
"metadata": {
"creatorSource": "Frank Herbert"
}
}
],
"settings": {
"options": {
"allowPartialPurchase": true,
"collectBuyerEmail": "required",
"collectBuyerAddress": "optional",
"collectBuyerPhone": "off"
},
"commissionFeeFixed": {
"value": 1.99,
"currency": "USD"
},
"commissionFeePercent": 10,
"events": [
{
"type": "order",
"data": [
{
"type": "<string>",
"points": 123
}
],
"conditional": {
"type": "<string>",
"operator": "equals",
"value": "<string>"
}
}
]
},
"tags": {}
},
"metadata": {}
}
}Unique identifier for the cart
"crt_sa2aEsCz9PRM"
Optional buyer details to prefill at checkout. When provided, the returned checkoutUrl will include these as query params.
Show child attributes
Was this page helpful?