diff --git a/lib/resources.js b/lib/resources.js index fbe202a5e3..5b311e9b39 100644 --- a/lib/resources.js +++ b/lib/resources.js @@ -93,5 +93,8 @@ module.exports = { }), TestHelpers: resourceNamespace('testHelpers', { TestClocks: require('./resources/TestHelpers/TestClocks'), + Terminal: resourceNamespace('terminal', { + Readers: require('./resources/TestHelpers/Terminal/Readers'), + }), }), }; diff --git a/lib/resources/Terminal/Readers.js b/lib/resources/Terminal/Readers.js index e0f9d8f5d0..05a8a53ef5 100644 --- a/lib/resources/Terminal/Readers.js +++ b/lib/resources/Terminal/Readers.js @@ -33,4 +33,24 @@ module.exports = StripeResource.extend({ method: 'DELETE', path: '/{reader}', }), + + cancelAction: stripeMethod({ + method: 'POST', + path: '/{reader}/cancel_action', + }), + + processPaymentIntent: stripeMethod({ + method: 'POST', + path: '/{reader}/process_payment_intent', + }), + + processSetupIntent: stripeMethod({ + method: 'POST', + path: '/{reader}/process_setup_intent', + }), + + setReaderDisplay: stripeMethod({ + method: 'POST', + path: '/{reader}/set_reader_display', + }), }); diff --git a/lib/resources/TestHelpers/Terminal/Readers.js b/lib/resources/TestHelpers/Terminal/Readers.js new file mode 100644 index 0000000000..ab660b0f95 --- /dev/null +++ b/lib/resources/TestHelpers/Terminal/Readers.js @@ -0,0 +1,15 @@ +// File generated from our OpenAPI spec + +'use strict'; + +const StripeResource = require('../../../StripeResource'); +const stripeMethod = StripeResource.method; + +module.exports = StripeResource.extend({ + path: 'test_helpers/terminal/readers', + + presentPaymentMethod: stripeMethod({ + method: 'POST', + path: '/{reader}/present_payment_method', + }), +}); diff --git a/test/resources/Integration.spec.js b/test/resources/Integration.spec.js index c35a013481..292a73a230 100644 --- a/test/resources/Integration.spec.js +++ b/test/resources/Integration.spec.js @@ -42,3 +42,14 @@ describe('Charges Resource', () => { }); }); }); + +describe('Reader Resource', () => { + describe('presentPaymentMethod', () => { + it('Sends the correct request', async () => { + const reader = await stripe.testHelpers.terminal.readers.presentPaymentMethod( + 'rdr_123' + ); + expect(reader).to.not.be.null; + }); + }); +}); diff --git a/test/resources/TestHelpers/Terminal/Readers.spec.js b/test/resources/TestHelpers/Terminal/Readers.spec.js new file mode 100644 index 0000000000..e6c49945ad --- /dev/null +++ b/test/resources/TestHelpers/Terminal/Readers.spec.js @@ -0,0 +1,23 @@ +'use strict'; + +const stripe = require('../../../../testUtils').getSpyableStripe(); + +const expect = require('chai').expect; + +describe('Terminal', () => { + describe('Readers Resource', () => { + describe('update', () => { + it('Sends the correct request', () => { + stripe.testHelpers.terminal.readers.presentPaymentMethod('rdr_123'); + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'POST', + url: + '/v1/test_helpers/terminal/readers/rdr_123/present_payment_method', + headers: {}, + data: {}, + settings: {}, + }); + }); + }); + }); +}); diff --git a/types/2020-08-27/Charges.d.ts b/types/2020-08-27/Charges.d.ts index aa1952f0e0..8a072151f6 100644 --- a/types/2020-08-27/Charges.d.ts +++ b/types/2020-08-27/Charges.d.ts @@ -108,7 +108,7 @@ declare module 'stripe' { /** * ID of the balance transaction that describes the reversal of the balance on your account due to payment failure. */ - failure_balance_transaction?: string | Stripe.BalanceTransaction | null; + failure_balance_transaction: string | Stripe.BalanceTransaction | null; /** * Error code explaining reason for charge failure if available (see [the errors section](https://stripe.com/docs/api#errors) for a list of codes). @@ -2136,7 +2136,10 @@ declare module 'stripe' { ): Promise>; /** - * Search for charges you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language) + * Search for charges you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + * Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + * conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + * to an hour behind during outages. Search functionality is not available to merchants in India. */ search( params: ChargeSearchParams, diff --git a/types/2020-08-27/Checkout/Sessions.d.ts b/types/2020-08-27/Checkout/Sessions.d.ts index 2b286513c4..a1a1e86d7d 100644 --- a/types/2020-08-27/Checkout/Sessions.d.ts +++ b/types/2020-08-27/Checkout/Sessions.d.ts @@ -1310,7 +1310,7 @@ declare module 'stripe' { metadata?: Stripe.MetadataParam; /** - * The product's name, meant to be displayable to the customer. Whenever this product is sold via a subscription, name will show up on associated invoice line item descriptions. + * The product's name, meant to be displayable to the customer. */ name: string; diff --git a/types/2020-08-27/Customers.d.ts b/types/2020-08-27/Customers.d.ts index 7f52cb96c0..cb410f9839 100644 --- a/types/2020-08-27/Customers.d.ts +++ b/types/2020-08-27/Customers.d.ts @@ -827,7 +827,10 @@ declare module 'stripe' { ): ApiListPromise; /** - * Search for customers you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language) + * Search for customers you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + * Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + * conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + * to an hour behind during outages. Search functionality is not available to merchants in India. */ search( params: CustomerSearchParams, diff --git a/types/2020-08-27/Invoices.d.ts b/types/2020-08-27/Invoices.d.ts index e3b57c6f01..fcfd7f580d 100644 --- a/types/2020-08-27/Invoices.d.ts +++ b/types/2020-08-27/Invoices.d.ts @@ -620,7 +620,7 @@ declare module 'stripe' { /** * If paying by `us_bank_account`, this sub-hash contains details about the ACH direct debit payment method options to pass to the invoice's PaymentIntent. */ - us_bank_account?: PaymentMethodOptions.UsBankAccount | null; + us_bank_account: PaymentMethodOptions.UsBankAccount | null; } namespace PaymentMethodOptions { @@ -2163,7 +2163,10 @@ declare module 'stripe' { ): Promise>; /** - * Search for invoices you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language) + * Search for invoices you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + * Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + * conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + * to an hour behind during outages. Search functionality is not available to merchants in India. */ search( params: InvoiceSearchParams, diff --git a/types/2020-08-27/PaymentIntents.d.ts b/types/2020-08-27/PaymentIntents.d.ts index 74cd855163..6fe796cdd6 100644 --- a/types/2020-08-27/PaymentIntents.d.ts +++ b/types/2020-08-27/PaymentIntents.d.ts @@ -577,7 +577,7 @@ declare module 'stripe' { /** * The type of the microdeposit sent to the customer. Used to distinguish between different verification methods. */ - microdeposit_type?: VerifyWithMicrodeposits.MicrodepositType | null; + microdeposit_type: VerifyWithMicrodeposits.MicrodepositType | null; } namespace VerifyWithMicrodeposits { @@ -5994,7 +5994,10 @@ declare module 'stripe' { ): Promise>; /** - * Search for PaymentIntents you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language) + * Search for PaymentIntents you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + * Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + * conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + * to an hour behind during outages. Search functionality is not available to merchants in India. */ search( params: PaymentIntentSearchParams, diff --git a/types/2020-08-27/Plans.d.ts b/types/2020-08-27/Plans.d.ts index d2a79c4256..cbcb0b814a 100644 --- a/types/2020-08-27/Plans.d.ts +++ b/types/2020-08-27/Plans.d.ts @@ -297,7 +297,7 @@ declare module 'stripe' { metadata?: Stripe.MetadataParam; /** - * The product's name, meant to be displayable to the customer. Whenever this product is sold via a subscription, name will show up on associated invoice line item descriptions. + * The product's name, meant to be displayable to the customer. */ name: string; diff --git a/types/2020-08-27/Prices.d.ts b/types/2020-08-27/Prices.d.ts index e105817016..5188144a02 100644 --- a/types/2020-08-27/Prices.d.ts +++ b/types/2020-08-27/Prices.d.ts @@ -323,7 +323,7 @@ declare module 'stripe' { metadata?: Stripe.MetadataParam; /** - * The product's name, meant to be displayable to the customer. Whenever this product is sold via a subscription, name will show up on associated invoice line item descriptions. + * The product's name, meant to be displayable to the customer. */ name: string; @@ -619,7 +619,10 @@ declare module 'stripe' { list(options?: RequestOptions): ApiListPromise; /** - * Search for prices you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language) + * Search for prices you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + * Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + * conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + * to an hour behind during outages. Search functionality is not available to merchants in India. */ search( params: PriceSearchParams, diff --git a/types/2020-08-27/Products.d.ts b/types/2020-08-27/Products.d.ts index 5f5588f968..fe20129f40 100644 --- a/types/2020-08-27/Products.d.ts +++ b/types/2020-08-27/Products.d.ts @@ -64,7 +64,7 @@ declare module 'stripe' { metadata: Stripe.Metadata; /** - * The product's name, meant to be displayable to the customer. Whenever this product is sold via a subscription, name will show up on associated invoice line item descriptions. + * The product's name, meant to be displayable to the customer. */ name: string; @@ -157,7 +157,7 @@ declare module 'stripe' { interface ProductCreateParams { /** - * The product's name, meant to be displayable to the customer. Whenever this product is sold via a subscription, name will show up on associated invoice line item descriptions. + * The product's name, meant to be displayable to the customer. */ name: string; @@ -320,7 +320,7 @@ declare module 'stripe' { metadata?: Stripe.Emptyable; /** - * The product's name, meant to be displayable to the customer. Whenever this product is sold via a subscription, name will show up on associated invoice line item descriptions. + * The product's name, meant to be displayable to the customer. */ name?: string; @@ -503,7 +503,10 @@ declare module 'stripe' { ): Promise>; /** - * Search for products you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language) + * Search for products you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + * Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + * conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + * to an hour behind during outages. Search functionality is not available to merchants in India. */ search( params: ProductSearchParams, diff --git a/types/2020-08-27/SetupIntents.d.ts b/types/2020-08-27/SetupIntents.d.ts index 3baff16a63..e506d4186f 100644 --- a/types/2020-08-27/SetupIntents.d.ts +++ b/types/2020-08-27/SetupIntents.d.ts @@ -271,7 +271,7 @@ declare module 'stripe' { /** * The type of the microdeposit sent to the customer. Used to distinguish between different verification methods. */ - microdeposit_type?: VerifyWithMicrodeposits.MicrodepositType | null; + microdeposit_type: VerifyWithMicrodeposits.MicrodepositType | null; } namespace VerifyWithMicrodeposits { diff --git a/types/2020-08-27/Subscriptions.d.ts b/types/2020-08-27/Subscriptions.d.ts index e8f4a31aef..10542941f6 100644 --- a/types/2020-08-27/Subscriptions.d.ts +++ b/types/2020-08-27/Subscriptions.d.ts @@ -272,7 +272,7 @@ declare module 'stripe' { /** * This sub-hash contains details about the ACH direct debit payment method options to pass to invoices created by the subscription. */ - us_bank_account?: PaymentMethodOptions.UsBankAccount | null; + us_bank_account: PaymentMethodOptions.UsBankAccount | null; } namespace PaymentMethodOptions { @@ -1705,7 +1705,10 @@ declare module 'stripe' { ): Promise>; /** - * Search for subscriptions you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language) + * Search for subscriptions you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + * Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + * conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + * to an hour behind during outages. Search functionality is not available to merchants in India. */ search( params: SubscriptionSearchParams, diff --git a/types/2020-08-27/Terminal/Readers.d.ts b/types/2020-08-27/Terminal/Readers.d.ts index 907bc041ae..534bfbbcdb 100644 --- a/types/2020-08-27/Terminal/Readers.d.ts +++ b/types/2020-08-27/Terminal/Readers.d.ts @@ -17,6 +17,11 @@ declare module 'stripe' { */ object: 'terminal.reader'; + /** + * The most recent action performed by the reader. + */ + action?: Reader.Action | null; + deleted?: void; /** @@ -66,6 +71,123 @@ declare module 'stripe' { } namespace Reader { + interface Action { + /** + * Failure code, only set if status is `failed`. + */ + failure_code: string | null; + + /** + * Detailed failure message, only set if status is `failed`. + */ + failure_message: string | null; + + /** + * Represents a reader action to process a payment intent + */ + process_payment_intent?: Action.ProcessPaymentIntent; + + /** + * Represents a reader action to process a setup intent + */ + process_setup_intent?: Action.ProcessSetupIntent; + + /** + * Represents a reader action to set the reader display + */ + set_reader_display?: Action.SetReaderDisplay; + + /** + * Status of the action performed by the reader. + */ + status: Action.Status; + + /** + * Type of action performed by the reader. + */ + type: Action.Type; + } + + namespace Action { + interface ProcessPaymentIntent { + /** + * Most recent PaymentIntent processed by the reader. + */ + payment_intent: string | Stripe.PaymentIntent; + } + + interface ProcessSetupIntent { + generated_card?: string; + + /** + * Most recent SetupIntent processed by the reader. + */ + setup_intent: string | Stripe.SetupIntent; + } + + interface SetReaderDisplay { + /** + * Cart object to be displayed by the reader. + */ + cart: SetReaderDisplay.Cart | null; + + /** + * Type of information to be displayed by the reader. + */ + type: 'cart'; + } + + namespace SetReaderDisplay { + interface Cart { + /** + * 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; + + /** + * List of line items in the cart. + */ + line_items: Array; + + /** + * Tax amount for the entire cart. A positive integer in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + */ + tax: number | null; + + /** + * Total amount for the entire cart, including tax. A positive integer in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + */ + total: number; + } + + namespace Cart { + interface LineItem { + /** + * The amount of the line item. A positive integer in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + */ + amount: number; + + /** + * Description of the line item. + */ + description: string; + + /** + * The quantity of the line item. + */ + quantity: number; + } + } + } + + type Status = 'failed' | 'in_progress' | 'succeeded'; + + type Type = + | 'process_payment_intent' + | 'process_setup_intent' + | 'set_reader_display'; + } + type DeviceType = | 'bbpos_chipper2x' | 'bbpos_wisepad3' @@ -180,6 +302,116 @@ declare module 'stripe' { interface ReaderDeleteParams {} + interface ReaderCancelActionParams { + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + } + + interface ReaderProcessPaymentIntentParams { + /** + * PaymentIntent ID + */ + payment_intent: string; + + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + + /** + * Configuration overrides + */ + process_config?: ReaderProcessPaymentIntentParams.ProcessConfig; + } + + namespace ReaderProcessPaymentIntentParams { + interface ProcessConfig { + /** + * Override showing a tipping selection screen on this transaction. + */ + skip_tipping?: boolean; + } + } + + interface ReaderProcessSetupIntentParams { + /** + * Customer Consent Collected + */ + customer_consent_collected: boolean; + + /** + * SetupIntent ID + */ + setup_intent: string; + + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + } + + interface ReaderSetReaderDisplayParams { + /** + * Type + */ + type: 'cart'; + + /** + * Cart + */ + cart?: ReaderSetReaderDisplayParams.Cart; + + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + } + + namespace ReaderSetReaderDisplayParams { + interface Cart { + /** + * 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; + + /** + * Array of line items that were purchased. + */ + line_items: Array; + + /** + * The amount of tax in cents. + */ + tax?: number; + + /** + * Total balance of cart due in cents. + */ + total: number; + } + + namespace Cart { + interface LineItem { + /** + * The price of the item in cents. + */ + amount: number; + + /** + * The description or name of the item. + */ + description: string; + + /** + * The quantity of the line item being purchased. + */ + quantity: number; + } + } + } + class ReadersResource { /** * Creates a new Reader object. @@ -244,6 +476,46 @@ declare module 'stripe' { id: string, options?: RequestOptions ): Promise>; + + /** + * Cancels the current reader action + */ + cancelAction( + id: string, + params?: ReaderCancelActionParams, + options?: RequestOptions + ): Promise>; + cancelAction( + id: string, + options?: RequestOptions + ): Promise>; + + /** + * Initiates a payment flow on a Reader + */ + processPaymentIntent( + id: string, + params: ReaderProcessPaymentIntentParams, + options?: RequestOptions + ): Promise>; + + /** + * Initiates a setup intent flow on a Reader + */ + processSetupIntent( + id: string, + params: ReaderProcessSetupIntentParams, + options?: RequestOptions + ): Promise>; + + /** + * Sets reader display + */ + setReaderDisplay( + id: string, + params: ReaderSetReaderDisplayParams, + options?: RequestOptions + ): Promise>; } } } diff --git a/types/2020-08-27/TestHelpers/Terminal/Readers.d.ts b/types/2020-08-27/TestHelpers/Terminal/Readers.d.ts new file mode 100644 index 0000000000..de21a57f84 --- /dev/null +++ b/types/2020-08-27/TestHelpers/Terminal/Readers.d.ts @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec + +declare module 'stripe' { + namespace Stripe { + namespace TestHelpers { + namespace Terminal { + interface ReaderPresentPaymentMethodParams { + /** + * Simulated card present data + */ + card_present?: ReaderPresentPaymentMethodParams.CardPresent; + + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + + /** + * Simulated payment type + */ + type?: 'card_present'; + } + + namespace ReaderPresentPaymentMethodParams { + interface CardPresent { + /** + * Card Number + */ + number?: string; + } + } + } + + namespace Terminal { + class ReadersResource { + /** + * Presents a payment method on a simulated reader. Can be used to simulate accepting a payment, saving a card or refunding a transaction + */ + presentPaymentMethod( + id: string, + params?: ReaderPresentPaymentMethodParams, + options?: RequestOptions + ): Promise>; + presentPaymentMethod( + id: string, + options?: RequestOptions + ): Promise>; + } + } + } + } +} diff --git a/types/2020-08-27/index.d.ts b/types/2020-08-27/index.d.ts index 0eb7736d65..48e6266076 100644 --- a/types/2020-08-27/index.d.ts +++ b/types/2020-08-27/index.d.ts @@ -97,6 +97,7 @@ /// /// /// +/// /// /// /// @@ -213,6 +214,9 @@ declare module 'stripe' { }; testHelpers: { testClocks: Stripe.TestHelpers.TestClocksResource; + terminal: { + readers: Stripe.TestHelpers.Terminal.ReadersResource; + }; }; /** * API Errors