JavaScript
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.checkout.purchase('crt_sa2aEsCz9PRM', {
buyer: {
name: {
firstName: 'John',
middleName: 'A.',
lastName: 'Doe',
},
email: 'johnadoe@example.com',
phone: '+1234567890',
shippingAddress: {
line1: '123 Main St',
line2: 'Apt 4B',
city: 'Anytown',
province: 'CA',
postalCode: '12345',
countryCode: 'US',
},
card: {
nameOnCard: {
firstName: 'John',
middleName: 'A.',
lastName: 'Doe',
},
details: { cardToken: 'card_live_SimDpKU9cmU7tvdUXHzOeLudtgfadQVnbof' },
billingAddress: {
line1: '123 Main St',
line2: 'Apt 4B',
city: 'Anytown',
province: 'CA',
postalCode: '12345',
countryCode: 'US',
},
},
},
mode: 'async',
});
console.log(response.details);{
"refId": "<string>",
"products": [
{
"link": "<string>",
"quantity": 123,
"merchant": "<string>",
"host": "<string>",
"affiliateProductLink": "<string>",
"selectedOptions": [
"<string>"
],
"selectedShipping": {
"id": "<string>",
"value": "<string>"
}
}
],
"details": {
"hasAccount": true,
"name": {
"firstName": "<string>",
"lastName": "<string>",
"middleName": "<string>"
},
"card": {
"nameOnCard": {
"firstName": "<string>",
"lastName": "<string>",
"middleName": "<string>"
},
"details": {},
"billingAddress": {
"line1": "<string>",
"city": "<string>",
"province": "<string>",
"postalCode": "<string>",
"countryCode": "<string>",
"name": {
"firstName": "<string>",
"lastName": "<string>",
"middleName": "<string>"
},
"email": "jsmith@example.com",
"phone": {
"countryCode": "<string>",
"nationalNumber": "<string>",
"e164": "<string>",
"country": "<string>"
},
"line2": "<string>"
}
},
"email": "<string>",
"phone": {
"countryCode": "<string>",
"nationalNumber": "<string>",
"e164": "<string>",
"country": "<string>"
},
"shippingAddress": {
"line1": "<string>",
"city": "<string>",
"province": "<string>",
"postalCode": "<string>",
"countryCode": "<string>",
"name": {
"firstName": "<string>",
"lastName": "<string>",
"middleName": "<string>"
},
"email": "jsmith@example.com",
"phone": {
"countryCode": "<string>",
"nationalNumber": "<string>",
"e164": "<string>",
"country": "<string>"
},
"line2": "<string>"
},
"settings": {
"collectEmail": true,
"collectAddress": true,
"collectPhone": true
}
},
"result": {
"items": [
{
"productLink": "<string>",
"confirmationNumber": "<string>",
"quantity": 123,
"costs": {
"total": {
"value": 123
},
"subtotal": {
"value": 123
},
"tax": {
"value": 123
},
"shipping": {
"value": 123
},
"discount": {
"value": 123
}
},
"shipping": {
"id": "<string>",
"name": "<string>",
"cost": {
"value": 123
},
"timeEstimate": "<string>",
"minDate": "<string>",
"maxDate": "<string>"
},
"appliedCoupon": {
"code": "<string>",
"savedAmount": {
"value": 123
}
},
"metadata": {}
}
],
"costs": {
"subtotal": {
"value": 123
},
"commissionFee": {
"value": 123
},
"total": {
"value": 123
}
}
},
"error": {}
}Cart
Cart Purchase
Initiate the purchase process for a cart. Requests are async by default, or use mode=sync to wait up to 30 seconds for completion.
POST
/
cart
/
{cartId}
/
purchase
JavaScript
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.checkout.purchase('crt_sa2aEsCz9PRM', {
buyer: {
name: {
firstName: 'John',
middleName: 'A.',
lastName: 'Doe',
},
email: 'johnadoe@example.com',
phone: '+1234567890',
shippingAddress: {
line1: '123 Main St',
line2: 'Apt 4B',
city: 'Anytown',
province: 'CA',
postalCode: '12345',
countryCode: 'US',
},
card: {
nameOnCard: {
firstName: 'John',
middleName: 'A.',
lastName: 'Doe',
},
details: { cardToken: 'card_live_SimDpKU9cmU7tvdUXHzOeLudtgfadQVnbof' },
billingAddress: {
line1: '123 Main St',
line2: 'Apt 4B',
city: 'Anytown',
province: 'CA',
postalCode: '12345',
countryCode: 'US',
},
},
},
mode: 'async',
});
console.log(response.details);{
"refId": "<string>",
"products": [
{
"link": "<string>",
"quantity": 123,
"merchant": "<string>",
"host": "<string>",
"affiliateProductLink": "<string>",
"selectedOptions": [
"<string>"
],
"selectedShipping": {
"id": "<string>",
"value": "<string>"
}
}
],
"details": {
"hasAccount": true,
"name": {
"firstName": "<string>",
"lastName": "<string>",
"middleName": "<string>"
},
"card": {
"nameOnCard": {
"firstName": "<string>",
"lastName": "<string>",
"middleName": "<string>"
},
"details": {},
"billingAddress": {
"line1": "<string>",
"city": "<string>",
"province": "<string>",
"postalCode": "<string>",
"countryCode": "<string>",
"name": {
"firstName": "<string>",
"lastName": "<string>",
"middleName": "<string>"
},
"email": "jsmith@example.com",
"phone": {
"countryCode": "<string>",
"nationalNumber": "<string>",
"e164": "<string>",
"country": "<string>"
},
"line2": "<string>"
}
},
"email": "<string>",
"phone": {
"countryCode": "<string>",
"nationalNumber": "<string>",
"e164": "<string>",
"country": "<string>"
},
"shippingAddress": {
"line1": "<string>",
"city": "<string>",
"province": "<string>",
"postalCode": "<string>",
"countryCode": "<string>",
"name": {
"firstName": "<string>",
"lastName": "<string>",
"middleName": "<string>"
},
"email": "jsmith@example.com",
"phone": {
"countryCode": "<string>",
"nationalNumber": "<string>",
"e164": "<string>",
"country": "<string>"
},
"line2": "<string>"
},
"settings": {
"collectEmail": true,
"collectAddress": true,
"collectPhone": true
}
},
"result": {
"items": [
{
"productLink": "<string>",
"confirmationNumber": "<string>",
"quantity": 123,
"costs": {
"total": {
"value": 123
},
"subtotal": {
"value": 123
},
"tax": {
"value": 123
},
"shipping": {
"value": 123
},
"discount": {
"value": 123
}
},
"shipping": {
"id": "<string>",
"name": "<string>",
"cost": {
"value": 123
},
"timeEstimate": "<string>",
"minDate": "<string>",
"maxDate": "<string>"
},
"appliedCoupon": {
"code": "<string>",
"savedAmount": {
"value": 123
}
},
"metadata": {}
}
],
"costs": {
"subtotal": {
"value": 123
},
"commissionFee": {
"value": 123
},
"total": {
"value": 123
}
}
},
"error": {}
}Authorizations
Path Parameters
Unique identifier for the cart
Example:
"crt_sa2aEsCz9PRM"
Body
application/json
Show child attributes
Show child attributes
Response mode. Use sync to wait up to 30 seconds for the backing worker flow to complete.
Available options:
async, sync Example:
"async"
Per-product overrides keyed by product URL. Items with quantity null or 0 are excluded.
Show child attributes
Show child attributes
Example:
{
"https://www.nike.com/u/custom-nike-ja-3-by-you-10002205": { "quantity": 2 }
}Settings for what information to collect
Show child attributes
Show child attributes
Additional metadata for the request
Show child attributes
Show child attributes
Response
Cart purchase queued successfully, use refId to check status and retrieve results
Pattern:
^[a-zA-Z]{3}-ref_[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}$Available options:
pending, processing, complete, cancelled Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?
⌘I