Overview
Sets customer billing information for the cart. This endpoint is typically used when the billing address differs from the shipping address. The billing information is used for payment processing and invoice generation.
If billing address is the same as shipping address, you may skip this endpoint and the shipping address will be used for billing by default.
Request Body
Customer’s first name for billing
Customer’s last name for billing
Primary billing address line
Secondary billing address line (apartment, suite, etc.)
Billing state or province code (e.g., “CA”, “NY”) or full name
Billing ZIP or postal code
Billing country code in ISO 3166-1 alpha-2 format (e.g., “US”, “CA”)
Billing contact phone number
Billing contact email address
Response
Returns a complete ShoppingCart object with updated billing information. The cart totals remain unchanged as billing address doesn’t affect shipping or tax calculations.
When to Use Billing Info
Common Scenarios
- Different Billing Address: Customer’s credit card billing address differs from shipping
- Gift Orders: Shipping to recipient but billing to purchaser
- Business Orders: Shipping to office but billing to headquarters
- Digital Products: No shipping address but billing address required
Default Behavior
If this endpoint is not called:
- Shipping address is used as billing address
- Both addresses must match for payment processing
Code Examples
curl -X POST https://api.firmly.work/api/v2/domains/staging.luma.gift/cart/billing-info \
-H "x-firmly-authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"first_name": "Jane",
"last_name": "Doe",
"address1": "456 Billing Street",
"address2": "Suite 100",
"city": "Billing City",
"state_or_province": "NY",
"postal_code": "10001",
"country": "US",
"phone": "555-987-6543",
"email": "[email protected]"
}'
Response Example
{
"line_items": [...],
"shipments": [...],
"shipping_info": {
"first_name": "John",
"last_name": "Smith",
"address1": "123 Main Street",
"address2": "Apt 4B",
"city": "Anytown",
"state_or_province": "CA",
"postal_code": "12345",
"country": "US",
"phone": "555-123-4567",
"email": "[email protected]"
},
"billing_info": {
"first_name": "Jane",
"last_name": "Doe",
"address1": "456 Billing Street",
"address2": "Suite 100",
"city": "Billing City",
"state_or_province": "NY",
"postal_code": "10001",
"country": "US",
"phone": "555-987-6543",
"email": "[email protected]"
},
"sub_total": {
"currency": "USD",
"value": 44.00,
"number": 4400,
"symbol": "$"
},
"shipping_total": {
"currency": "USD",
"value": 9.99,
"number": 999,
"symbol": "$"
},
"tax_total": {
"currency": "USD",
"value": 4.40,
"number": 440,
"symbol": "$"
},
"total": {
"currency": "USD",
"value": 58.39,
"number": 5839,
"symbol": "$"
},
"schema_version": "2.0"
}
Billing Address Validation
Similar to shipping address, the billing address undergoes validation:
- Country Support: Verifies billing country is supported
- State/Province: Validates state/province for the country
- Required Fields: Ensures all required fields are present
- Email Format: Validates email address format
Billing address validation is primarily for data integrity. Payment processors may perform additional address verification (AVS) during payment processing.
Billing Address Behavior
- Independent from Shipping: Billing info can be set independently of shipping
- No Tax Impact: Billing address doesn’t affect tax calculations (taxes based on shipping destination)
- Schema Compatibility: Uses the same address schema as shipping for consistency
- Session Storage: Billing info is stored in the cart session
Error Responses
{
"code": 400,
"error": "ErrorCountryNotSupported",
"description": "Country 'XX' is not supported by this merchant"
}
Common Errors
| Error Code | Description | Resolution |
|---|
ErrorCartNotFound | Cart does not exist | Verify cart ID and domain |
ErrorCountryNotSupported | Billing country not supported | Use supported country |
ErrorInvalidState | Invalid state/province for country | Verify state code |
ErrorInvalidInputBody | Request body validation failed | Check request format |
MissingAuthHeader | Missing authorization header | Include x-firmly-authorization |
InvalidToken | Invalid JWT token | Refresh authentication token |
Checkout Flow Integration
The typical checkout flow sequence:
- Add Items to Cart - Build the cart
- Set Shipping Info - Add shipping address
- Set Billing Info - Add billing address (this endpoint)
- Set Consents - Handle consent management
- Complete Order - Complete the purchase