Repository: stripe/stripe-node
Pull request #890 (2020-05-11 22:39:35)

Add support for the `LineItem` resource and APIs
Codegen for openapi 72527e3

r? @richardm-stripe 
cc @stripe/api-libraries 


Patch:
diff --git a/lib/resources/Checkout/Sessions.js b/lib/resources/Checkout/Sessions.js
index 57e601eb..f68a79c5 100644
--- a/lib/resources/Checkout/Sessions.js
+++ b/lib/resources/Checkout/Sessions.js
@@ -1,9 +1,16 @@
 'use strict';
 
 const StripeResource = require('../../StripeResource');
+const stripeMethod = StripeResource.method;
 
 module.exports = StripeResource.extend({
   path: 'checkout/sessions',
 
   includeBasic: ['create', 'list', 'retrieve'],
+
+  listLineItems: stripeMethod({
+    method: 'GET',
+    path: '/{session}/line_items',
+    methodType: 'list',
+  }),
 });
diff --git a/types/2020-03-02/Accounts.d.ts b/types/2020-03-02/Accounts.d.ts
index 02613b5f..99ed9b8d 100644
--- a/types/2020-03-02/Accounts.d.ts
+++ b/types/2020-03-02/Accounts.d.ts
@@ -2024,9 +2024,6 @@ declare module 'stripe' {
       /**
        * With [Connect](https://stripe.com/docs/connect), you can create Stripe accounts for your users.
        * To do this, you'll first need to [register your platform](https://dashboard.stripe.com/account/applications/settings).
-       *
-       * For Standard accounts, parameters other than country, email, and type
-       * are used to prefill the account application that we ask the account holder to complete.
        */
       create(
         params?: AccountCreateParams,
diff --git a/types/2020-03-02/Checkout/Sessions.d.ts b/types/2020-03-02/Checkout/Sessions.d.ts
index b25aaad8..b0685e11 100644
--- a/types/2020-03-02/Checkout/Sessions.d.ts
+++ b/types/2020-03-02/Checkout/Sessions.d.ts
@@ -57,6 +57,11 @@ declare module 'stripe' {
          */
         display_items?: Array<Session.DisplayItem>;
 
+        /**
+         * The line items purchased by the customer. [Expand](https://stripe.com/docs/api/expanding_objects) this field to include it in the response.
+         */
+        line_items?: ApiList<Stripe.LineItem> | null;
+
         /**
          * Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
          */
@@ -547,6 +552,8 @@ declare module 'stripe' {
          * A list of items the customer is purchasing. Use this parameter for
          * one-time payments or adding invoice line items to a subscription (used
          * in conjunction with `subscription_data`).
+         * There is a maximum of 100 line items, however it is recommended to
+         * consolidate line items if there are more than a few dozen.
          */
         line_items?: Array<SessionCreateParams.LineItem>;
 
@@ -623,6 +630,16 @@ declare module 'stripe' {
            */
           name?: string;
 
+          /**
+           * The ID of the price object.
+           */
+          price?: string;
+
+          /**
+           * Data used to generate a new price object inline.
+           */
+          price_data?: LineItem.PriceData;
+
           /**
            * The quantity of the line item being purchased.
            */
@@ -634,6 +651,53 @@ declare module 'stripe' {
           tax_rates?: Array<string>;
         }
 
+        namespace LineItem {
+          interface PriceData {
+            /**
+             * Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
+             */
+            currency: string;
+
+            /**
+             * The ID of the product that this price will belong to.
+             */
+            product: string;
+
+            /**
+             * The recurring components of a price such as `interval` and `usage_type`.
+             */
+            recurring?: PriceData.Recurring;
+
+            /**
+             * A positive integer in %s (or 0 for a free price) representing how much to charge.
+             */
+            unit_amount?: number;
+
+            /**
+             * Same as `unit_amount`, but accepts a decimal value with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set.
+             */
+            unit_amount_decimal?: string;
+          }
+
+          namespace PriceData {
+            interface Recurring {
+              /**
+               * Specifies billing frequency. Either `day`, `week`, `month` or `year`.
+               */
+              interval: Recurring.Interval;
+
+              /**
+               * The number of intervals between subscription billings. For example, `interval=month` and `interval_count=3` bills every 3 months. Maximum of one year interval allowed (1 year, 12 months, or 52 weeks).
+               */
+              interval_count?: number;
+            }
+
+            namespace Recurring {
+              type Interval = 'day' | 'month' | 'week' | 'year';
+            }
+          }
+        }
+
         type Locale =
           | 'auto'
           | 'da'
@@ -1167,6 +1231,19 @@ declare module 'stripe' {
           options?: RequestOptions
         ): ApiListPromise<Stripe.Checkout.Session>;
         list(options?: RequestOptions): ApiListPromise<Stripe.Checkout.Session>;
+
+        /**
+         * When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
+         */
+        listLineItems(
+          id: string,
+          params?: LineItemListParams,
+          options?: RequestOptions
+        ): ApiListPromise<Stripe.LineItem>;
+        listLineItems(
+          id: string,
+          options?: RequestOptions
+        ): ApiListPromise<Stripe.LineItem>;
       }
     }
   }
diff --git a/types/2020-03-02/Coupons.d.ts b/types/2020-03-02/Coupons.d.ts
index 0b3f24cf..97b199f0 100644
--- a/types/2020-03-02/Coupons.d.ts
+++ b/types/2020-03-02/Coupons.d.ts
@@ -133,7 +133,7 @@ declare module 'stripe' {
       expand?: Array<string>;
 
       /**
-       * Unique string of your choice that will be used to identify this coupon when applying it to a customer. This is often a specific code you'll give to your customer to use when signing up (e.g., `FALL25OFF`). If you don't want to specify a particular code, you can leave the ID blank and we'll generate a random code for you.
+       * Unique string of your choice that will be used to identify this coupon when applying it to a customer. If you don't want to specify a particular code, you can leave the ID blank and we'll generate a random code for you.
        */
       id?: string;
 
diff --git a/types/2020-03-02/Invoices.d.ts b/types/2020-03-02/Invoices.d.ts
index 69624f4b..6d47037a 100644
--- a/types/2020-03-02/Invoices.d.ts
+++ b/types/2020-03-02/Invoices.d.ts
@@ -296,7 +296,7 @@ declare module 'stripe' {
       total_tax_amounts: Array<Invoice.TotalTaxAmount> | null;
 
       /**
-       * If specified, the funds from the invoice will be transferred to the destination and the ID of the resulting transfer will be found on the invoice's charge.
+       * The account (if any) the payment will be attributed to for tax reporting, and where funds from the payment will be transferred to for the invoice.
        */
       transfer_data?: Invoice.TransferData | null;
 
diff --git a/types/2020-03-02/LineItems.d.ts b/types/2020-03-02/LineItems.d.ts
new file mode 100644
index 00000000..ec342f39
--- /dev/null
+++ b/types/2020-03-02/LineItems.d.ts
@@ -0,0 +1,81 @@
+declare module 'stripe' {
+  namespace Stripe {
+    /**
+     * The LineItem object.
+     */
+    interface LineItem {
+      /**
+       * Unique identifier for the object.
+       */
+      id: string;
+
+      /**
+       * String representing the object's type. Objects of the same type share the same value.
+       */
+      object: 'item';
+
+      /**
+       * Total before any discounts or taxes is applied.
+       */
+      amount_subtotal: number | null;
+
+      /**
+       * Total after discounts and taxes.
+       */
+      amount_total: number | null;
+
+      /**
+       * Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
+       */
+      currency: string;
+
+      /**
+       * An arbitrary string attached to the object. Often useful for displaying to users. Defaults to product name.
+       */
+      description: string;
+
+      /**
+       * Prices define the unit cost, currency, and (optional) billing cycle for both recurring and one-time purchases of products.
+       * Products help you track inventory or provisioning, and prices help you track payment terms. Different physical goods or levels of service should be represented by products, and pricing options should be represented by prices. This approach lets you change prices without having to change your provisioning scheme.
+       *
+       * For example, you might have a single "gold" product that has prices for $10/month, $100/year, and €9 once.
+       *
+       * Related guides: [Set up a subscription](https://stripe.com/docs/billing/subscriptions/set-up-subscription), [create an invoice](https://stripe.com/docs/billing/invoices/create), and more about [products and prices](https://stripe.com/docs/billing/prices-guide).
+       */
+      price: Stripe.Price;
+
+      /**
+       * The quantity of products being purchased.
+       */
+      quantity: number | null;
+
+      /**
+       * The taxes applied to the line item.
+       */
+      taxes: Array<LineItem.Tax> | null;
+    }
+
+    namespace LineItem {
+      interface Tax {
+        /**
+         * Amount of tax for this line item.
+         */
+        amount: number;
+
+        /**
+         * Tax rates can be applied to invoices and subscriptions to collect tax.
+         *
+         * Related guide: [Tax Rates](https://stripe.com/docs/billing/taxes/tax-rates).
+         */
+        rate: Stripe.TaxRate;
+      }
+    }
+
+    interface LineItemListParams extends PaginationParams {
+      /**
+       * Specifies which fields in the response should be expanded.
+       */
+      expand?: Array<string>;
+    }
+  }
+}
diff --git a/types/2020-03-02/Plans.d.ts b/types/2020-03-02/Plans.d.ts
index 1e0425c7..96fc4816 100644
--- a/types/2020-03-02/Plans.d.ts
+++ b/types/2020-03-02/Plans.d.ts
@@ -25,12 +25,12 @@ declare module 'stripe' {
       aggregate_usage: Plan.AggregateUsage | null;
 
       /**
-       * The amount in %s to be charged on the interval specified.
+       * The unit amount in %s to be charged, represented as a whole integer if possible.
        */
       amount: number | null;
 
       /**
-       * Same as `amount`, but contains a decimal value with at most 12 decimal places.
+       * The unit amount in %s to be charged, represented as a decimal string with at most 12 decimal places.
        */
       amount_decimal: string | null;
 
diff --git a/types/2020-03-02/Prices.d.ts b/types/2020-03-02/Prices.d.ts
index 0ce4d81b..0a19b41d 100644
--- a/types/2020-03-02/Prices.d.ts
+++ b/types/2020-03-02/Prices.d.ts
@@ -87,12 +87,12 @@ declare module 'stripe' {
       type: Price.Type;
 
       /**
-       * The unit amount in %s to be charged.
+       * The unit amount in %s to be charged, represented as a whole integer if possible.
        */
       unit_amount: number | null;
 
       /**
-       * Same as `amount`, but contains a decimal value with at most 12 decimal places.
+       * The unit amount in %s to be charged, represented as a decimal string with at most 12 decimal places.
        */
       unit_amount_decimal: string | null;
     }
diff --git a/types/2020-03-02/Subscriptions.d.ts b/types/2020-03-02/Subscriptions.d.ts
index 28db25ad..8b27bd35 100644
--- a/types/2020-03-02/Subscriptions.d.ts
+++ b/types/2020-03-02/Subscriptions.d.ts
@@ -183,7 +183,7 @@ declare module 'stripe' {
       tax_percent: number | null;
 
       /**
-       * If specified, the funds from the subscription's invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges.
+       * The account (if any) the subscription's payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the subscription's invoices.
        */
       transfer_data?: Subscription.TransferData | null;
 
diff --git a/types/2020-03-02/index.d.ts b/types/2020-03-02/index.d.ts
index 03e7dda6..c69b9621 100644
--- a/types/2020-03-02/index.d.ts
+++ b/types/2020-03-02/index.d.ts
@@ -46,6 +46,7 @@
 ///<reference path='./Issuing/Cards.d.ts' />
 ///<reference path='./Issuing/Disputes.d.ts' />
 ///<reference path='./Issuing/Transactions.d.ts' />
+///<reference path='./LineItems.d.ts' />
 ///<reference path='./LoginLinks.d.ts' />
 ///<reference path='./Mandates.d.ts' />
 ///<reference path='./OrderItems.d.ts' />


Test patch:
diff --git a/test/resources/Checkout/Sessions.spec.js b/test/resources/Checkout/Sessions.spec.js
index a8dab657..9b7c35b5 100644
--- a/test/resources/Checkout/Sessions.spec.js
+++ b/test/resources/Checkout/Sessions.spec.js
@@ -51,5 +51,18 @@ describe('Checkout', () => {
         });
       });
     });
+
+    describe('listLineItems', () => {
+      it('Sends the correct request', () => {
+        stripe.checkout.sessions.listLineItems('cs_123');
+        expect(stripe.LAST_REQUEST).to.deep.equal({
+          method: 'GET',
+          url: '/v1/checkout/sessions/cs_123/line_items',
+          headers: {},
+          data: {},
+          settings: {},
+        });
+      });
+    });
   });
 });