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 |
---|---|---|
currency | The currency used in the invoice (e.g., EUR) | No |
number | The invoice number. If not provided, an autoincrement number will be used | No |
customer_name | The name of the customer | Conditional (1) |
customer_address_city | The city where the customer resides | Conditional (1) |
customer_address_line1 | The customer's address | Conditional (1) |
customer_address_postal_code | The postal code of the customer's location (5 characters) | Conditional (1) |
customer_address_country | The country of the customer (2 characters) | Conditional (1) |
customer_address_state | The state or region of the customer | Conditional (1) |
customer_tax_id | The VAT number of the customer (for B2B transactions) | Conditional (2) |
customer_fiscal_code | The fiscal identifier of the customer (for B2C transactions) | Conditional (2) |
customer_codice_destinatario | The recipient code of the customer | No |
line_<n>_description | The description of the <n> line item | No (3)(4) |
line_<n>_unitprice | The unit price of the <n> line item in cents (without taxes included) | No (3)(4) |
line_<n>_quantity | The quantity of the <n> line item (defaults to 1) | No (3)(4) |
line_<n>_vatrate | The VAT rate of the <n> line item. The calculated tax amount will be added to the unit price | No (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,
Example:
<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:
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