Skip to content

Commit

Permalink
Merge pull request #1938 from stripe/latest-codegen-beta
Browse files Browse the repository at this point in the history
Update generated code for beta
  • Loading branch information
stripe-openapi[bot] authored Oct 26, 2023
2 parents b9e3b91 + eafe8ba commit 7f60f76
Show file tree
Hide file tree
Showing 49 changed files with 830 additions and 121 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 14.2.0 - 2023-10-26
* [#1939](https://github.com/stripe/stripe-node/pull/1939) Update generated code
* Add support for new value `balance_invalid_parameter` on enums `Invoice.last_finalization_error.code`, `PaymentIntent.last_payment_error.code`, `SetupAttempt.setup_error.code`, `SetupIntent.last_setup_error.code`, and `StripeError.code`
* Change `Issuing.Cardholder.individual.card_issuing` to be optional
* [#1940](https://github.com/stripe/stripe-node/pull/1940) Do not require passing apiVersion

## 14.2.0-beta.1 - 2023-10-17
* [#1935](https://github.com/stripe/stripe-node/pull/1935) Update generated code for beta
* [#1930](https://github.com/stripe/stripe-node/pull/1930) Update generated code for beta
Expand Down
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v605
v627
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ and instantiate it as `new Stripe()` with the latest API version.

```ts
import Stripe from 'stripe';
const stripe = new Stripe('sk_test_...', {
apiVersion: '2023-10-16',
});
const stripe = new Stripe('sk_test_...');

const createCustomer = async () => {
const params: Stripe.CustomerCreateParams = {
Expand Down Expand Up @@ -158,11 +156,13 @@ stripe.customers
});
});
```

### Usage with Deno

As of 11.16.0, stripe-node provides a `deno` export target. In your Deno project, import stripe-node using an npm specifier:

Import using npm specifiers:

```js
import Stripe from 'npm:stripe';
```
Expand All @@ -179,7 +179,6 @@ The package can be initialized with several options:
import ProxyAgent from 'https-proxy-agent';

const stripe = Stripe('sk_test_...', {
apiVersion: '2019-08-08',
maxNetworkRetries: 1,
httpAgent: new ProxyAgent(process.env.http_proxy),
timeout: 1000,
Expand Down Expand Up @@ -265,8 +264,8 @@ As of [v13](https://github.com/stripe/stripe-node/releases/tag/v13.0.0) stripe-n
const stripe = Stripe('sk_test_...', {
maxNetworkRetries: 0, // Disable retries
});

```

```js
const stripe = Stripe('sk_test_...', {
maxNetworkRetries: 2, // Retry a request twice before giving up
Expand Down Expand Up @@ -394,7 +393,7 @@ const stripe = require('stripe')('sk_test_...', {
name: 'MyAwesomePlugin',
version: '1.2.34', // Optional
url: 'https://myawesomeplugin.info', // Optional
}
},
});
```

Expand All @@ -406,7 +405,7 @@ const stripe = new Stripe(apiKey, {
name: 'MyAwesomePlugin',
version: '1.2.34', // Optional
url: 'https://myawesomeplugin.info', // Optional
}
},
});
```

Expand Down Expand Up @@ -496,6 +495,7 @@ const stripe = new Stripe('sk_test_...', {
Stripe has features in the beta phase that can be accessed via the beta version of this package.
We would love for you to try these and share feedback with us before these features reach the stable phase.
The beta versions can be installed in one of two ways

- To install the latest beta version, run the command `npm install stripe@beta --save`
- To install a specific beta version, replace the term "beta" in the above command with the version number like `npm install stripe@1.2.3-beta.1 --save`

Expand Down
4 changes: 1 addition & 3 deletions examples/webhook-signing/express/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import {AddressInfo} from 'net';

env.config();

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2023-08-16',
});
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

const webhookSecret: string = process.env.STRIPE_WEBHOOK_SECRET;

Expand Down
4 changes: 1 addition & 3 deletions examples/webhook-signing/koa/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const app = new Koa();
env.config();
const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET;

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2023-08-16',
});
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

const handleWebhook = async (ctx: Koa.ParameterizedContext, next: Koa.Next) => {
const sig = ctx.request.headers['stripe-signature'];
Expand Down
1 change: 0 additions & 1 deletion examples/webhook-signing/nestjs/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class AppController {
private readonly client: Stripe;
constructor(@Inject(ConfigService) private readonly config: ConfigService) {
this.client = new Stripe(this.config.get('Stripe.secret_key'), {
apiVersion: '2022-11-15',
typescript: true,
});
}
Expand Down
4 changes: 1 addition & 3 deletions examples/webhook-signing/nextjs/pages/api/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ const handler = async (
req: NextApiRequest,
res: NextApiResponse
): Promise<void> => {
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2023-08-16',
});
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

const webhookSecret: string = process.env.STRIPE_WEBHOOK_SECRET;

Expand Down
4 changes: 1 addition & 3 deletions examples/webhook-signing/test/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ env.config({
});

const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET;
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2023-08-16',
});
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

const payload = Buffer.from(
JSON.stringify(
Expand Down
4 changes: 0 additions & 4 deletions scripts/updateAPIVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ const main = () => {
'types/test/typescriptTest.ts',
'apiVersion: [\'"]API_VERSION[\'"]'
);
replaceAPIVersion(
'testProjects/mjs-ts/index.ts',
'apiVersion: [\'"]API_VERSION[\'"]'
);
};

if (require.main === module) {
Expand Down
2 changes: 1 addition & 1 deletion src/apiVersion.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// File generated from our OpenAPI spec

export const ApiVersion = '2023-10-16';
export const PreviewVersion = '2023-09-15.preview-v2';
export const PreviewVersion = '2023-10-26.preview-v2';
1 change: 1 addition & 0 deletions src/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export {Files} from './resources/Files.js';
export {InvoiceItems} from './resources/InvoiceItems.js';
export {Invoices} from './resources/Invoices.js';
export {Mandates} from './resources/Mandates.js';
export {Margins} from './resources/Margins.js';
export {OAuth} from './resources/OAuth.js';
export {Orders} from './resources/Orders.js';
export {PaymentIntents} from './resources/PaymentIntents.js';
Expand Down
20 changes: 20 additions & 0 deletions src/resources/Margins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// File generated from our OpenAPI spec

import {StripeResource} from '../StripeResource.js';
const stripeMethod = StripeResource.method;
export const Margins = StripeResource.extend({
create: stripeMethod({method: 'POST', fullPath: '/v1/billing/margins'}),
retrieve: stripeMethod({
method: 'GET',
fullPath: '/v1/billing/margins/{margin}',
}),
update: stripeMethod({
method: 'POST',
fullPath: '/v1/billing/margins/{margin}',
}),
list: stripeMethod({
method: 'GET',
fullPath: '/v1/billing/margins',
methodType: 'list',
}),
});
1 change: 0 additions & 1 deletion testProjects/cloudflare-pages/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export async function onRequestPost({env, request}) {
const body = await request.text();

const stripe = new Stripe(env.STRIPE_API_KEY, {
apiVersion: '2023-08-16',
httpClient: Stripe.createFetchHttpClient(),
});
const webCrypto = Stripe.createSubtleCryptoProvider();
Expand Down
4 changes: 2 additions & 2 deletions types/Accounts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ declare module 'stripe' {
currently_due: Array<string> | null;

/**
* This is typed as a string for consistency with `requirements.disabled_reason`, but it safe to assume `future_requirements.disabled_reason` is empty because fields in `future_requirements` will never disable the account.
* This is typed as a string for consistency with `requirements.disabled_reason`.
*/
disabled_reason: string | null;

Expand Down Expand Up @@ -907,7 +907,7 @@ declare module 'stripe' {
currently_due: Array<string> | null;

/**
* If the account is disabled, this string describes why. Can be `requirements.past_due`, `requirements.pending_verification`, `listed`, `platform_paused`, `rejected.fraud`, `rejected.listed`, `rejected.terms_of_service`, `rejected.other`, `under_review`, or `other`.
* If the account is disabled, this string describes why. [Learn more about handling verification issues](https://stripe.com/docs/connect/handling-api-verification). Can be `action_required.requested_capabilities`, `requirements.past_due`, `requirements.pending_verification`, `listed`, `platform_paused`, `rejected.fraud`, `rejected.incomplete_verification`, `rejected.listed`, `rejected.other`, `rejected.terms_of_service`, `under_review`, or `other`.
*/
disabled_reason: string | null;

Expand Down
5 changes: 5 additions & 0 deletions types/Checkout/SessionsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,11 @@ declare module 'stripe' {
* If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`.
*/
setup_future_usage?: Stripe.Emptyable<Paypal.SetupFutureUsage>;

/**
* The Stripe connected account IDs of the sellers on the platform for this transaction (optional). Only allowed when [separate charges and transfers](https://stripe.com/docs/connect/separate-charges-and-transfers) are used.
*/
subsellers?: Array<string>;
}

namespace Paypal {
Expand Down
62 changes: 60 additions & 2 deletions types/FundingInstructions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ declare module 'stripe' {

namespace BankTransfer {
interface FinancialAddress {
/**
* ABA Records contain U.S. bank account details per the ABA format.
*/
aba?: FinancialAddress.Aba;

/**
* Iban Records contain E.U. bank account details per the SEPA format.
*/
Expand All @@ -73,6 +78,11 @@ declare module 'stripe' {
*/
supported_networks?: Array<FinancialAddress.SupportedNetwork>;

/**
* SWIFT Records contain U.S. bank account details per the SWIFT format.
*/
swift?: FinancialAddress.Swift;

/**
* The type of financial address
*/
Expand All @@ -85,6 +95,23 @@ declare module 'stripe' {
}

namespace FinancialAddress {
interface Aba {
/**
* The ABA account number
*/
account_number: string;

/**
* The bank name
*/
bank_name: string;

/**
* The ABA routing number
*/
routing_number: string;
}

interface Iban {
/**
* The name of the person or business that owns the bank account
Expand Down Expand Up @@ -141,9 +168,40 @@ declare module 'stripe' {
clabe: string;
}

type SupportedNetwork = 'bacs' | 'fps' | 'sepa' | 'spei' | 'zengin';
type SupportedNetwork =
| 'ach'
| 'bacs'
| 'domestic_wire_us'
| 'fps'
| 'sepa'
| 'spei'
| 'swift'
| 'zengin';

interface Swift {
/**
* The account number
*/
account_number: string;

/**
* The bank name
*/
bank_name: string;

/**
* The SWIFT code
*/
swift_code: string;
}

type Type = 'iban' | 'sort_code' | 'spei' | 'zengin';
type Type =
| 'aba'
| 'iban'
| 'sort_code'
| 'spei'
| 'swift'
| 'zengin';

interface Zengin {
/**
Expand Down
5 changes: 5 additions & 0 deletions types/InvoiceItems.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ declare module 'stripe' {
*/
livemode: boolean;

/**
* The margins which apply to the invoice item. When set, the `default_margins` on the invoice do not apply to this invoice item.
*/
margins?: Array<string | Stripe.Margin> | null;

/**
* Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
*/
Expand Down
10 changes: 10 additions & 0 deletions types/InvoiceItemsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ declare module 'stripe' {
*/
invoice?: string;

/**
* The ids of the margins to apply to the invoice item. When set, the `default_margins` on the invoice do not apply to this invoice item.
*/
margins?: Array<string>;

/**
* Set of [key-value pairs](https://stripe.com/docs/api/metadata) 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`.
*/
Expand Down Expand Up @@ -235,6 +240,11 @@ declare module 'stripe' {
*/
expand?: Array<string>;

/**
* The ids of the margins to apply to the invoice item. When set, the `default_margins` on the invoice do not apply to this invoice item.
*/
margins?: Stripe.Emptyable<Array<string>>;

/**
* Set of [key-value pairs](https://stripe.com/docs/api/metadata) 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`.
*/
Expand Down
22 changes: 22 additions & 0 deletions types/InvoiceLineItems.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ declare module 'stripe' {
*/
livemode: boolean;

/**
* The amount of margin calculated per margin for this line item.
*/
margin_amounts?: Array<InvoiceLineItem.MarginAmount> | null;

/**
* The margins applied to the line item. When set, the `default_margins` on the invoice do not apply to the line item. Use `expand[]=margins` to expand each margin.
*/
margins?: Array<string | Stripe.Margin> | null;

/**
* Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Note that for line items with `type=subscription` this will reflect the metadata of the subscription that caused the line item to be created.
*/
Expand Down Expand Up @@ -137,6 +147,18 @@ declare module 'stripe' {
discount: string | Stripe.Discount | Stripe.DeletedDiscount;
}

interface MarginAmount {
/**
* The amount, in cents (or local equivalent), of the reduction in line item amount.
*/
amount: number;

/**
* The margin that was applied to get this margin amount.
*/
margin: string | Stripe.Margin;
}

interface Period {
/**
* The end of the period, which must be greater than or equal to the start. This value is inclusive.
Expand Down
Loading

0 comments on commit 7f60f76

Please sign in to comment.