Home > Net >  Stripe doesn't support in order to create multiple line items on an invoice using API call
Stripe doesn't support in order to create multiple line items on an invoice using API call

Time:11-22

I'm creating an invoice using Stripe's API call. Based on stripe documentation, there is no amount parameters for generated invoice and I always get zero in amount_due.

Another issue is I want to add line items in generate invoice, but there is no places to add line items for generated invoice.

Here is my code;

$params = [
      'customer' => $stripeCustomer['stripeCustomerId'],
      'auto_advance' => true,
      'collection_method' => 'charge_automatically',
      'currency' => Str::lower($record['CurrencyCode']),
      'metadata' => $metaData,
    ];

$stripeInvoice = \Stripe\Invoice::create($params);

And stripe return object is here;

{
  "id": "in_1M6otQLHPCwYGWEgSQraCHVf",
  "object": "invoice",
  "account_country": "SG",
  "account_name": "Demo",
  "account_tax_ids": null,
  "amount_due": 0,
  "amount_paid": 0,
  "amount_remaining": 0,
  "application": null,
  "application_fee_amount": null,
  "attempt_count": 0,
  "attempted": false,
  "auto_advance": true,
  "automatic_tax": {
    "enabled": false,
    "status": null
  },
  "billing_reason": "manual",
  "charge": null,
  "collection_method": "charge_automatically",
  "created": 1669094376,
  "currency": "sgd",
  "custom_fields": null,
  "customer": "cus_MqVqznCTTb78Ct",
  "customer_address": {
    "city": "",
    "country": "",
    "line1": "",
    "line2": "",
    "postal_code": "",
    "state": ""
  },
  "customer_email": "[email protected]",
  "customer_name": "John Doe",
  "customer_phone": null,
  "customer_shipping": null,
  "customer_tax_exempt": "none",
  "customer_tax_ids": [
  ],
  "default_payment_method": null,
  "default_source": null,
  "default_tax_rates": [
  ],
  "description": null,
  "discount": null,
  "discounts": [
  ],
  "due_date": null,
  "ending_balance": null,
  "footer": null,
  "from_invoice": null,
  "hosted_invoice_url": null,
  "invoice_pdf": null,
  "last_finalization_error": null,
  "latest_revision": null,
  "lines": {
    "object": "list",
    "data": [
    ],
    "has_more": false,
    "total_count": 0,
    "url": "/v1/invoices/in_1M6otQLHPCwYGWEgSQraCHVf/lines"
  },
  "livemode": false,
  "metadata": {
    "invoiceNumber": "INV-0005",
    "invoiceId": "fcca9507-411d-4087-b940-03251402beab"
  },
  "next_payment_attempt": 1669097976,
  "number": null,
  "on_behalf_of": null,
  "paid": false,
  "paid_out_of_band": false,
  "payment_intent": null,
  "payment_settings": {
    "default_mandate": null,
    "payment_method_options": null,
    "payment_method_types": null
  },
  "period_end": 1669094376,
  "period_start": 1669094376,
  "post_payment_credit_notes_amount": 0,
  "pre_payment_credit_notes_amount": 0,
  "quote": null,
  "receipt_number": null,
  "rendering_options": null,
  "starting_balance": 0,
  "statement_descriptor": null,
  "status": "draft",
  "status_transitions": {
    "finalized_at": null,
    "marked_uncollectible_at": null,
    "paid_at": null,
    "voided_at": null
  },
  "subscription": null,
  "subtotal": 0,
  "subtotal_excluding_tax": 0,
  "tax": null,
  "test_clock": null,
  "total": 0,
  "total_discount_amounts": [
  ],
  "total_excluding_tax": 0,
  "total_tax_amounts": [
  ],
  "transfer_data": null,
  "webhooks_delivered_at": 1669094376
}

CodePudding user response:

Invoices Create API always creates an empty invoice first, then use Invoice Items Create API to add line items to the invoice later.

You may refer to the doc here for the step-by-step integration: https://stripe.com/docs/invoicing/integration

  • Related