Handling Invoices
Introduction
Simpler Checkout allows business customers (B2B) to request an invoice by providing their company details, such as VAT number and Billing Address, directly within the checkout flow.
When this feature is enabled, the Submit Order Request sent to your Platform Interface will contain an additional invoice object. This tutorial covers how to process that data and how to get the feature activated for your store.
Step 1: Activation
The Invoicing capability is not enabled by default. To start receiving invoice data:
- Ensure your Platform Interface is ready to parse the
invoiceobject (see Step 2). - Contact Simpler Support to enable the invoicing capability.
Step 2: Update the Order Submission Logic
When a shopper requests an invoice, the submit request will include the invoice property. You must map this to your internal accounting or ERP system.
The invoice object typically contains:
- Company Name
- VAT / Tax ID
- Billing Address (which may differ from the shipping address)
Implementation Example (PHP)
src/Controller/Simpler/SubmitController.php
class SimplerSubmitController extends AbstractController {
public function postData(Request $request): Response {
$requestData = json_decode($request->getContent(), true);
$orderData = $requestData['order'];
// 1. Initialize your order/cart as usual
$cart = CartService::createCart();
// ... (add items and shipping as shown in Basic Flow)
// 2. Check if an invoice was requested
if (!empty($orderData['invoice'])) {
$invoiceDetails = $orderData['invoice'];
// Map Simpler invoice data to your system
$cart->setInvoiceRequested(true);
$cart->setTaxId($invoiceDetails['vat_number']);
$cart->setCompanyName($invoiceDetails['company_name']);
// Check for a specific billing address inside the invoice object
if (!empty($invoiceDetails['billing_address'])) {
$cart->setBillingAddress($invoiceDetails['billing_address']);
}
}
$order = CheckoutService::createOrder($cart);
return $this->json([
'request_id' => $requestData['request_id'],
'order_id' => $order->getID()
]);
}
}