Create billto for a shipment [Deprecated] - Fabric
Create billto for a shipment [Deprecated]
cURL
curl --request POST \
--url https://prod01-apigw.yourcompany.fabric.zone/api-cart/bill-to/cart/{cartId} \
--header 'Content-Type: application/json' \
--data '
{
"paymentMethod": "Visa Credit",
"cardIdentifier": "1234",
"amount": 149.99,
"address": {
"street1": "123 Main Street",
"city": "Seattle",
"state": "WA",
"country": "United States of America",
"zipCode": "10008-1234",
"name": {
"first": "John",
"last": "Smith"
},
"email": "johnsmith@fabric.inc",
"attention": "Leave at the back door.",
"street2": "ABC Boulevard",
"kind": "TBD"
}
}
'
Python
import requests
url = "https://prod01-apigw.yourcompany.fabric.zone/api-cart/bill-to/cart/{cartId}"
payload = {
"paymentMethod": "Visa Credit",
"cardIdentifier": "1234",
"amount": 149.99,
"address": {
"street1": "123 Main Street",
"city": "Seattle",
"state": "WA",
"country": "United States of America",
"zipCode": "10008-1234",
"name": {
"first": "John",
"last": "Smith"
},
"email": "johnsmith@fabric.inc",
"attention": "Leave at the back door.",
"street2": "ABC Boulevard",
"kind": "TBD"
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
JavaScript (Fetch)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
paymentMethod: 'Visa Credit',
cardIdentifier: '1234',
amount: 149.99,
address: {
street1: '123 Main Street',
city: 'Seattle',
state: 'WA',
country: 'United States of America',
zipCode: '10008-1234',
name: {first: 'John', last: 'Smith'},
email: 'johnsmith@fabric.inc',
attention: 'Leave at the back door.',
street2: 'ABC Boulevard',
kind: 'TBD'
}
})
};
fetch('https://prod01-apigw.yourcompany.fabric.zone/api-cart/bill-to/cart/{cartId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://prod01-apigw.yourcompany.fabric.zone/api-cart/bill-to/cart/{cartId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'paymentMethod' => 'Visa Credit',
'cardIdentifier' => '1234',
'amount' => 149.99,
'address' => [
'street1' => '123 Main Street',
'city' => 'Seattle',
'state' => 'WA',
'country' => 'United States of America',
'zipCode' => '10008-1234',
'name' => [
'first' => 'John',
'last' => 'Smith'
],
'email' => 'johnsmith@fabric.inc',
'attention' => 'Leave at the back door.',
'street2' => 'ABC Boulevard',
'kind' => 'TBD'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
Response Examples
Successful Response (200)
{
"paymentMethod": "Visa Credit",
"cardIdentifier": "1234",
"amount": 149.99,
"address": {
"street1": "123 Main Street",
"city": "Seattle",
"state": "WA",
"country": "United States of America",
"zipCode": "10008-1234",
"name": {
"first": "John",
"last": "Smith"
},
"email": "johnsmith@fabric.inc",
"attention": "Leave at the back door.",
"street2": "ABC Boulevard",
"kind": "TBD",
"phone": {
"number": "123-456-7890",
"kind": "Mobile"
}
},
"billToId": 1,
"cart": "5e5818a84d030c206b2ffb02",
"_id": "5fee9d59f2f08a1b3cbdea08",
"createdAt": "2020-12-31T02:09:53.914Z",
"updatedAt": "2020-12-31T02:09:53.914Z"
}
Error Response (400)
{
"code": "CART_NOT_FOUND",
"message": "Cart not found."
}
Path Parameters
- cartId: Required string length:
24 (e.g., "5e5818a84d030c206b2ffb02")
Body Parameters
- paymentMethod: string, required (3 - 24 characters, e.g., "Visa Credit")
- cardIdentifier: string, required (4 characters, e.g., "1234")
- amount: number, required (x >= 0.01, e.g., 149.99)
- address: object, required (contains various nested attributes)
Response
- 200: Application/json Bill To For Shipment Created.