Skip to content

Commit

Permalink
API Updates (#1167)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe authored Jun 4, 2021
1 parent 686e47c commit 7e4528c
Show file tree
Hide file tree
Showing 17 changed files with 909 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module.exports = {
Subscriptions: require('./resources/Subscriptions'),
SubscriptionItems: require('./resources/SubscriptionItems'),
SubscriptionSchedules: require('./resources/SubscriptionSchedules'),
TaxCodes: require('./resources/TaxCodes'),
TaxRates: require('./resources/TaxRates'),
Tokens: require('./resources/Tokens'),
Topups: require('./resources/Topups'),
Expand Down
11 changes: 11 additions & 0 deletions lib/resources/TaxCodes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// File generated from our OpenAPI spec

'use strict';

const StripeResource = require('../StripeResource');

module.exports = StripeResource.extend({
path: 'tax_codes',

includeBasic: ['retrieve', 'list'],
});
32 changes: 32 additions & 0 deletions test/resources/TaxCodes.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

const stripe = require('../../testUtils').getSpyableStripe();
const expect = require('chai').expect;

describe('TaxCodes Resource', () => {
describe('retrieve', () => {
it('Sends the correct request', () => {
stripe.taxCodes.retrieve('txcd_123');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/tax_codes/txcd_123',
headers: {},
data: {},
settings: {},
});
});
});

describe('list', () => {
it('Sends the correct request', () => {
stripe.taxCodes.list();
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/tax_codes',
headers: {},
data: {},
settings: {},
});
});
});
});
71 changes: 71 additions & 0 deletions types/2020-08-27/Checkout/Sessions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ declare module 'stripe' {
*/
amount_total: number | null;

automatic_tax?: Session.AutomaticTax;

/**
* Describes whether Checkout should collect the customer's billing address.
*/
Expand Down Expand Up @@ -166,6 +168,22 @@ declare module 'stripe' {
}

namespace Session {
interface AutomaticTax {
/**
* Indicates whether automatic tax is enabled for the session
*/
enabled: boolean;

/**
* The status of the most recent automated tax calculation for this session.
*/
status: AutomaticTax.Status | null;
}

namespace AutomaticTax {
type Status = 'complete' | 'failed' | 'requires_location_inputs';
}

type BillingAddressCollection = 'auto' | 'required';

interface CustomerDetails {
Expand Down Expand Up @@ -703,6 +721,8 @@ declare module 'stripe' {
*/
allow_promotion_codes?: boolean;

automatic_tax?: SessionCreateParams.AutomaticTax;

/**
* Specify whether Checkout should collect the customer's billing address.
*/
Expand Down Expand Up @@ -738,6 +758,11 @@ declare module 'stripe' {
*/
customer_email?: string;

/**
* Controls what fields on Customer can be updated by the Checkout Session. Can only be provided when `customer` is provided.
*/
customer_update?: SessionCreateParams.CustomerUpdate;

/**
* The coupon or promotion code to apply to this Session. Currently, only up to one may be specified.
*/
Expand Down Expand Up @@ -812,8 +837,42 @@ declare module 'stripe' {
}

namespace SessionCreateParams {
interface AutomaticTax {
/**
* Set to true to enable automatic taxes.
*/
enabled: boolean;
}

type BillingAddressCollection = 'auto' | 'required';

interface CustomerUpdate {
/**
* Describes whether Checkout saves the billing address onto `customer.address`.
* To always collect a full billing address, use `billing_address_collection`. Defaults to `never`.
*/
address?: CustomerUpdate.Address;

/**
* Describes whether Checkout saves the name onto `customer.name`. Defaults to `never`.
*/
name?: CustomerUpdate.Name;

/**
* Describes whether Checkout saves shipping information onto `customer.shipping`.
* To collect shipping information, use `shipping_address_collection`. Defaults to `never`.
*/
shipping?: CustomerUpdate.Shipping;
}

namespace CustomerUpdate {
type Address = 'auto' | 'never';

type Name = 'auto' | 'never';

type Shipping = 'auto' | 'never';
}

interface Discount {
/**
* The ID of the coupon to apply to this Session.
Expand Down Expand Up @@ -924,6 +983,11 @@ declare module 'stripe' {
*/
recurring?: PriceData.Recurring;

/**
* Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed.
*/
tax_behavior?: PriceData.TaxBehavior;

/**
* A non-negative integer in %s representing how much to charge. One of `unit_amount` or `unit_amount_decimal` is required.
*/
Expand Down Expand Up @@ -956,6 +1020,11 @@ declare module 'stripe' {
* 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.
*/
name: string;

/**
* A [tax code](https://stripe.com/docs/tax/tax-codes) ID.
*/
tax_code?: string;
}

interface Recurring {
Expand All @@ -973,6 +1042,8 @@ declare module 'stripe' {
namespace Recurring {
type Interval = 'day' | 'month' | 'week' | 'year';
}

type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified';
}
}

Expand Down
76 changes: 76 additions & 0 deletions types/2020-08-27/Customers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ declare module 'stripe' {
*/
subscriptions?: ApiList<Stripe.Subscription>;

tax?: Customer.Tax;

/**
* Describes the customer's tax exemption status. One of `none`, `exempt`, or `reverse`. When set to `reverse`, invoice and receipt PDFs include the text **"Reverse charge"**.
*/
Expand Down Expand Up @@ -186,6 +188,56 @@ declare module 'stripe' {
tracking_number?: string | null;
}

interface Tax {
/**
* Surfaces if automatic tax computation is possible given the current customer location information.
*/
automatic_tax: Tax.AutomaticTax;

/**
* A recent IP address of the customer used for tax reporting and tax location inference.
*/
ip_address: string | null;

/**
* The customer's location as identified by Stripe Tax.
*/
location: Tax.Location | null;
}

namespace Tax {
type AutomaticTax =
| 'failed'
| 'not_collecting'
| 'supported'
| 'unrecognized_location';

interface Location {
/**
* The customer's country as identified by Stripe Tax.
*/
country: string;

/**
* The data source used to infer the customer's location.
*/
source: Location.Source;

/**
* The customer's state, county, province, or region as identified by Stripe Tax.
*/
state: string | null;
}

namespace Location {
type Source =
| 'billing_address'
| 'ip_address'
| 'payment_method'
| 'shipping_destination';
}
}

type TaxExempt = 'exempt' | 'none' | 'reverse';
}

Expand Down Expand Up @@ -286,6 +338,11 @@ declare module 'stripe' {

source?: string;

/**
* Tax details about the customer.
*/
tax?: CustomerCreateParams.Tax;

/**
* The customer's tax exemption. One of `none`, `exempt`, or `reverse`.
*/
Expand Down Expand Up @@ -346,6 +403,13 @@ declare module 'stripe' {
phone?: string;
}

interface Tax {
/**
* A recent IP address of the customer used for tax reporting and tax location inference. Stripe recommends updating the IP address when a new PaymentMethod is attached or the address field on the customer is updated. We recommend against updating this field more frequently since it could result in unexpected tax location/reporting outcomes.
*/
ip_address?: Stripe.Emptyable<string>;
}

type TaxExempt = 'exempt' | 'none' | 'reverse';

interface TaxIdDatum {
Expand Down Expand Up @@ -489,6 +553,11 @@ declare module 'stripe' {

source?: string;

/**
* Tax details about the customer.
*/
tax?: CustomerUpdateParams.Tax;

/**
* The customer's tax exemption. One of `none`, `exempt`, or `reverse`.
*/
Expand Down Expand Up @@ -549,6 +618,13 @@ declare module 'stripe' {
phone?: string;
}

interface Tax {
/**
* A recent IP address of the customer used for tax reporting and tax location inference. Stripe recommends updating the IP address when a new PaymentMethod is attached or the address field on the customer is updated. We recommend against updating this field more frequently since it could result in unexpected tax location/reporting outcomes.
*/
ip_address?: Stripe.Emptyable<string>;
}

type TaxExempt = 'exempt' | 'none' | 'reverse';
}

Expand Down
18 changes: 18 additions & 0 deletions types/2020-08-27/InvoiceItems.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ declare module 'stripe' {
*/
product: string;

/**
* Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed.
*/
tax_behavior?: PriceData.TaxBehavior;

/**
* A positive integer in %s (or 0 for a free price) representing how much to charge.
*/
Expand All @@ -283,6 +288,10 @@ declare module 'stripe' {
*/
unit_amount_decimal?: string;
}

namespace PriceData {
type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified';
}
}

interface InvoiceItemRetrieveParams {
Expand Down Expand Up @@ -395,6 +404,11 @@ declare module 'stripe' {
*/
product: string;

/**
* Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed.
*/
tax_behavior?: PriceData.TaxBehavior;

/**
* A positive integer in %s (or 0 for a free price) representing how much to charge.
*/
Expand All @@ -405,6 +419,10 @@ declare module 'stripe' {
*/
unit_amount_decimal?: string;
}

namespace PriceData {
type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified';
}
}

interface InvoiceItemListParams extends PaginationParams {
Expand Down
Loading

0 comments on commit 7e4528c

Please sign in to comment.