Create an invoice
Let's create our first invoice with three payments:
curl --request POST \
--url https://api.maroo.us/v1/invoices \
--header "accept: application/json" \
--header "authorization: Bearer $API_TOKEN" \
--header "content-type: application/json" \
--data '
{
"contact": {
"type": "Business",
"name": "Sarah Collins",
"email": "[email protected]"
},
"totalAmount": 180000,
"paymentSchedule": [
{
"dueDate": "2024-01-01",
"amount": 60000
},
{
"dueDate": "2024-02-01",
"amount": 60000
},
{
"dueDate": "2024-03-01",
"amount": 60000
}
],
"paymentMethods": [
"DebitCard",
"CreditCard",
"BankAccount"
],
"enableAutoreminders": true,
"note": "Wedding Photography Services",
"deliveryMethod": "Email"
}'
The response could be the following:
{
"timestamp": "2023-11-30T19:50:13.751Z",
"data": {
"id": "bc7f89ac-bb8e-4895-a03a-6db3e4584e2c",
"contactId": "bc93d14a-3fce-46c5-ad25-11688787e6bd",
"totalAmount": 180000,
"paymentSchedule": [
{
"id": "beb94571-1199-4777-a0d3-a231547b1ee2",
"amount": 60000,
"dueDate": "2024-01-01",
"status": "Due",
"fee": null,
"paymentDate": null
},
{
"id": "989955c8-8284-4d98-833c-aa404027d989",
"amount": 60000,
"dueDate": "2024-02-01",
"status": "Due",
"fee": null,
"paymentDate": null
},
{
"id": "ec82689c-5e56-41b0-b1ae-d9fb5b9e0484",
"amount": 60000,
"dueDate": "2024-03-01",
"status": "Due",
"fee": null,
"paymentDate": null
}
],
"paymentMethods": [
"DebitCard",
"CreditCard",
"BankAccount"
],
"ccEmails": [],
"enableAutoreminders": true,
"note": "Wedding Photography Services",
"deliveryMethod": "Email",
"paymentLink": "https://pay.maroo.us/flowers/r/ZTI5yxeL"
},
"error": null
}
Update the payment schedule
Imagine we want to keep the first payment unchanged, update the second payment, and delete the third one. We specify a new payment schedule which includes:
- the first payment is specified with the ID returned by the API and
dueDate
andamount
unchanged - the second payment is specified with the ID returned by the API and
dueDate
andamount
updated
The third payment is not included, as we want to delete it.
curl --request PATCH \
--url https://api.maroo.us/v1/invoices/bc7f89ac-bb8e-4895-a03a-6db3e4584e2c \
--header "accept: application/json" \
--header "authorization: Bearer $API_TOKEN" \
--header "content-type: application/json" \
--data '
{
"totalAmount": 140000,
"paymentSchedule": [
{
"id": "beb94571-1199-4777-a0d3-a231547b1ee2",
"dueDate": "2024-01-01",
"amount": 60000
},
{
"id": "989955c8-8284-4d98-833c-aa404027d989",
"dueDate": "2024-02-15",
"amount": 80000
}
]
}'
{
"timestamp": "2023-11-30T19:50:13.751Z",
"data": {
"id": "bc7f89ac-bb8e-4895-a03a-6db3e4584e2c",
"contactId": "bc93d14a-3fce-46c5-ad25-11688787e6bd",
"totalAmount": 140000,
"paymentSchedule": [
{
"id": "beb94571-1199-4777-a0d3-a231547b1ee2",
"amount": 60000,
"dueDate": "2024-01-01",
"status": "Due",
"fee": null,
"paymentDate": null
},
{
"id": "989955c8-8284-4d98-833c-aa404027d989",
"amount": 80000,
"dueDate": "2024-02-05",
"status": "Due",
"fee": null,
"paymentDate": null
}
],
"paymentMethods": [
"DebitCard",
"CreditCard",
"BankAccount"
],
"ccEmails": [],
"enableAutoreminders": true,
"note": "Wedding Photography Services",
"deliveryMethod": "Email",
"paymentLink": "https://pay.maroo.us/flowers/r/ZTI5yxeL"
},
"error": null
}
If you want to add a new payment, you should provide a payment schedule with the existing payments unchanged and new payments included (with no ID).
curl --request PATCH \
--url https://api.maroo.us/v1/invoices/bc7f89ac-bb8e-4895-a03a-6db3e4584e2c \
--header "accept: application/json" \
--header "authorization: Bearer $API_TOKEN" \
--header "content-type: application/json" \
--data '
{
"totalAmount": 190000,
"paymentSchedule": [
{
"id": "beb94571-1199-4777-a0d3-a231547b1ee2",
"dueDate": "2024-01-01",
"amount": 60000
},
{
"id": "989955c8-8284-4d98-833c-aa404027d989",
"dueDate": "2024-02-15",
"amount": 80000
},
{
"dueDate": "2024-05-15",
"amount": 50000
}
]
}'