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 thePaymentIntent
. Here's a breakdown of the fields:Metadata Field | Description | Required and notes |
---|---|---|
customer_name | The name of the customer (invoices only) | Conditional (1)(5) |
customer_address_city | The city where the customer resides | Conditional (1)(5) |
customer_address_line1 | The customer's address | Conditional (1)(5) |
customer_address_postal_code | The postal code of the customer's location (5 characters) | Conditional (1)(5) |
customer_address_country | The country of the customer (2 characters) | Conditional (1)(5) |
customer_address_state | The state or region of the customer | Conditional (1)(5) |
customer_tax_id | The VAT number of the customer (for B2B transactions) | Conditional (2)(5) |
customer_fiscal_code | The fiscal identifier of the customer (for B2C transactions) | Conditional (2)(5) |
customer_codice_destinatario | The recipient code of the customer | No (5) |
number | The invoice number. In absence, the automatic numbering will be used (if configured) | No (5) |
line_<n>_description | The description of the <n>th line item | No (3)(4) |
line_<n>_unitprice | The unit price of the <n>th line item in cents (without taxes included) | No (3)(4) |
line_<n>_quantity | The quantity of the <n>th line item (defaults to 1) | No (3)(4) |
line_<n>_vatrate | The VAT rate of the <n>th line item. The calculated tax amount will be added to the unit price | No (3)(4) |
Note 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).
Note 2
Eithercustomer_tax_id
or customer_fiscal_code
must be provided in case the customer is a guest.Note 3
Where indicated,<n>
must be an integer starting from 1.i.e.:
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.Note 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.
Note 5
The metadata will be considered only if the app is creating an invoice document. If a receipt is being created instead, the metadata will be ignored.
Example
Here's an example of how to create a checkout session with metadata:
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