code: import stripe
  stripe.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
  
  stripe.CreditNote.create(
    invoice="in_1LSdb92eZvKYlo2CJvl4iJuW",
    lines=[
      {
        "type": "invoice_line_item",
        "invoice_line_item":
        "il_1LSdb92eZvKYlo2Cg5Kr2nEp",
        "quantity": 1,
      },
    ],
  )
  '''Response {
    "id": "cn_1LSdb92eZvKYlo2C0JdIQVHd",
    "object": "credit_note",
    "amount": 857,
    "created": 1659517839,
    "currency": "usd",
    "customer": "cus_8TEMHVY5moxIPI",
    "customer_balance_transaction": null,
    "discount_amount": 0,
    "discount_amounts": [],
    "invoice": "in_1LSdb92eZvKYlo2CJvl4iJuW",
    "lines": {
      "object": "list",
      "data": [
        {
          "id": "cnli_1LSdb92eZvKYlo2Cu4lDIS7X",
          "object": "credit_note_line_item",
          "amount": 357,
          "amount_excluding_tax": 357,
          "description": "My First Invoice Item (created for API docs)",
          "discount_amount": 0,
          "discount_amounts": [],
          "invoice_line_item": "il_1LSdb92eZvKYlo2Cg5Kr2nEp",
          "livemode": false,
          "quantity": 1,
          "tax_amounts": [
            {
              "amount": 57,
              "inclusive": false,
              "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6"
            }
          ],
          "tax_rates": [
            {
              "id": "txr_1LSdb92eZvKYlo2CboQRs5G6",
              "object": "tax_rate",
              "active": true,
              "country": "DE",
              "created": 1659517839,
              "description": "VAT Germany",
              "display_name": "VAT",
              "inclusive": false,
              "jurisdiction": "DE",
              "livemode": false,
              "metadata": {},
              "percentage": 19.0,
              "state": null,
              "tax_type": "vat"
            }
          ],
          "type": "invoice_line_item",
          "unit_amount": null,
          "unit_amount_decimal": null,
          "unit_amount_excluding_tax": "357"
        },
        {
          "id": "cnli_1LSdb92eZvKYlo2C9yhKwMbp",
          "object": "credit_note_line_item",
          "amount": 500,
          "amount_excluding_tax": 500,
          "description": "Service credit",
          "discount_amount": 0,
          "discount_amounts": [],
          "livemode": false,
          "quantity": 1,
          "tax_amounts": [],
          "tax_rates": [],
          "type": "custom_line_item",
          "unit_amount": 500,
          "unit_amount_decimal": "500",
          "unit_amount_excluding_tax": "500"
        }
      ],
      "has_more": false,
      "url": "/v1/credit_notes/cn_1LSdb92eZvKYlo2C0JdIQVHd/lines"
    },
    "livemode": false,
    "memo": null,
    "metadata": {},
    "number": "ABCD-1234-CN-01",
    "out_of_band_amount": null,
    "pdf": "https://pay.stripe.com/credit_notes/acct_1032D82eZvKYlo2C/cnst_123456789/pdf?s=ap",
    "reason": null,
    "refund": null,
    "status": "issued",
    "subtotal": 857,
    "subtotal_excluding_tax": 857,
    "tax_amounts": [
      {
        "amount": 57,
        "inclusive": false,
        "tax_rate": "txr_1LSdb92eZvKYlo2CboQRs5G6"
      }
    ],
    "total": 857,
    "total_excluding_tax": null,
    "type": "pre_payment",
    "voided_at": null
  }'''
nl: Create a credit noteIssue a credit note to adjust the amount of a finalized invoice. For a status=open invoice, a credit note reduces
  its amount_due. For a status=paid invoice, a credit note does not affect its amount_due. Instead, it can result
  in any combination of the following:
  
  Refund: create a new refund (using refund_amount) or link an existing refund (using refund).
  Customer balance credit: credit the customer’s balance (using credit_amount) which will be automatically applied to their next invoice when it’s finalized.
  Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using out_of_band_amount).
  
  For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total.
  You may issue multiple credit notes for an invoice. Each credit note will increment the invoice’s pre_payment_credit_notes_amount
  or post_payment_credit_notes_amount depending on its status at the time of credit note creation.Parameters invoice required ID of the invoice. lines optional array of hashes Line items that make up the credit note.Show child parameters memo optional The credit note’s memo appears on the credit note PDF. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. reason optional Reason for issuing this credit note, one of duplicate, fraudulent, order_change, or product_unsatisfactoryMore parametersExpand all  amount optional   credit_amount optional   out_of_band_amount optional   refund optional   refund_amount optional ReturnsReturns a credit note object if the call succeeded