Checkout and payments

Even if your Stripe integration doesn't utilize Stripe Billing products, you can still make use of the A-Cube e-invoicing Stripe app. This can be done by supplying some metadata during the creation of the checkout session.

The metadata information should be linked to the PaymentIntent. Here's a breakdown of the fields:
Metadata FieldDescriptionRequired
currencyThe currency used in the invoice (e.g., EUR)No
numberThe invoice number. If not provided, an autoincrement number will be usedNo
customer_nameThe name of the customerConditional (1)
customer_address_cityThe city where the customer residesConditional (1)
customer_address_line1The customer's addressConditional (1)
customer_address_postal_codeThe postal code of the customer's location (5 characters)Conditional (1)
customer_address_countryThe country of the customer (2 characters)Conditional (1)
customer_address_stateThe state or region of the customerConditional (1)
customer_tax_idThe VAT number of the customer (for B2B transactions)Conditional (2)
customer_fiscal_codeThe fiscal identifier of the customer (for B2C transactions)Conditional (2)
customer_codice_destinatarioThe recipient code of the customerNo
line_<n>_descriptionThe description of the <n> line itemNo (3)(4)
line_<n>_unitpriceThe unit price of the <n> line item in cents (without taxes included)No (3)(4)
line_<n>_quantityThe quantity of the <n> line item (defaults to 1)No (3)(4)
line_<n>_vatrateThe VAT rate of the <n> line item. The calculated tax amount will be added to the unit priceNo (3)(4)
info

(1) All fields related to the customer are mandatory if a Stripe Customer object is not being used (i.e., the customer for whom the payment is being made is a guest).

info
(2) Either customer_tax_id or customer_fiscal_code must be provided in case the customer is a guest.
info
(3) Where indicated, <n> must be an integer starting from 1.
Example: line_1_description, line_1_unitprice, line_1_quantity, line_1_vatrate, line_2_description, line_2_unitprice, line_2_quantity, line_2_vatrate, etc.
info

(4) If you do not provide any line item metadata, the document will be created with a single line item containing the total amount of the payment and a sample description. The default VAT rate specified in the app settings will be used.


Here's an example of how to create a checkout session with metadata:

Copy
Copied
stripe checkout sessions create  \
--mode=payment \
--success-url="https://acubeapi.com" \
--cancel-url="https://acubeapi.com" \
-d "line_items[0][price]"="your first Stripe product identifier here" \
-d "line_items[0][quantity]"=5 \
-d "line_items[1][price]"="your second Stripe product identifier here" \
-d "line_items[1][quantity]"=10 \
-d "payment_intent_data[metadata][currency]"="eur" \
-d "payment_intent_data[metadata][customer_name]"="my customer" \
-d "payment_intent_data[metadata][customer_address_city]"="Milan" \
-d "payment_intent_data[metadata][customer_address_line1]"="street a" \
-d "payment_intent_data[metadata][customer_address_postal_code]"="12345" \
-d "payment_intent_data[metadata][customer_address_country]"="IT" \
-d "payment_intent_data[metadata][customer_address_state]"="MI" \
-d "payment_intent_data[metadata][customer_tax_id]"="12345678901" \
-d "payment_intent_data[metadata][line_1_description]"="fresh eggs!" \
-d "payment_intent_data[metadata][line_1_unitprice]"="100" \  # 1.00 EUR
-d "payment_intent_data[metadata][line_1_quantity]"="5" \
-d "payment_intent_data[metadata][line_1_vatrate]"="4" \  # 4% VAT rate -> 0.04 EUR
-d "payment_intent_data[metadata][line_2_description]"="tomato" \
-d "payment_intent_data[metadata][line_2_unitprice]"="50" \  # 0.50 EUR
-d "payment_intent_data[metadata][line_2_quantity]"="10" \
-d "payment_intent_data[metadata][line_2_vatrate]"="10"  # 10% VAT rate -> 0.05 EUR