import CheckoutIntents from 'checkout-intents';
const client = new CheckoutIntents({
apiKey: 'My API Key',
});
const checkoutIntent = await client.checkoutIntents.create({
buyer: {
address1: '123 Main St',
city: 'New York',
country: 'United States',
email: '[email protected]',
firstName: 'John',
lastName: 'Doe',
phone: '+1234567890',
postalCode: '10001',
province: 'NY',
},
productUrl: 'productUrl',
quantity: 1,
});
console.log(checkoutIntent);{
"buyer": {
"postalCode": "10001",
"country": "United States",
"province": "NY",
"city": "New York",
"address1": "123 Main St",
"phone": "+1234567890",
"email": "[email protected]",
"lastName": "Doe",
"firstName": "John",
"address2": "Apt 1"
},
"quantity": 123,
"productUrl": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"id": "<string>",
"state": "retrieving_offer",
"variantSelections": [
{
"value": "Small, Red, XS, L, etc.",
"label": "Size, Color, etc."
}
]
}Create a checkout intent with the given request body.
import CheckoutIntents from 'checkout-intents';
const client = new CheckoutIntents({
apiKey: 'My API Key',
});
const checkoutIntent = await client.checkoutIntents.create({
buyer: {
address1: '123 Main St',
city: 'New York',
country: 'United States',
email: '[email protected]',
firstName: 'John',
lastName: 'Doe',
phone: '+1234567890',
postalCode: '10001',
province: 'NY',
},
productUrl: 'productUrl',
quantity: 1,
});
console.log(checkoutIntent);{
"buyer": {
"postalCode": "10001",
"country": "United States",
"province": "NY",
"city": "New York",
"address1": "123 Main St",
"phone": "+1234567890",
"email": "[email protected]",
"lastName": "Doe",
"firstName": "John",
"address2": "Apt 1"
},
"quantity": 123,
"productUrl": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"id": "<string>",
"state": "retrieving_offer",
"variantSelections": [
{
"value": "Small, Red, XS, L, etc.",
"label": "Size, Color, etc."
}
]
}Rye API key
Show child attributes
255"10001"
"United States"
255"NY"
255"New York"
255"123 Main St"
"+1234567890"
255"Doe"
255"John"
255"Apt 1"
1
Created
Show child attributes
255"10001"
"United States"
255"NY"
255"New York"
255"123 Main St"
"+1234567890"
255"Doe"
255"John"
255"Apt 1"
retrieving_offer Was this page helpful?