Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update generated code for beta #2261

Open
wants to merge 30 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
84f92d2
Update generated code for v1473
stripe-openapi[bot] Feb 7, 2025
54d423e
Add Next.js App Router webhook example that leverages Route Handlers …
jsteele-stripe Feb 7, 2025
5c6c7bc
Merge upstream and update generated code for v1473
stripe-openapi[bot] Feb 8, 2025
d8d85fa
Update generated code for v1479
stripe-openapi[bot] Feb 10, 2025
1178155
Update generated code for v1481
stripe-openapi[bot] Feb 11, 2025
f55d9e5
Update generated code for v1483
stripe-openapi[bot] Feb 11, 2025
4ea95af
Update generated code for v1485
stripe-openapi[bot] Feb 12, 2025
7216769
Update generated code for v1486
stripe-openapi[bot] Feb 12, 2025
6ac7408
Update generated code for v1487
stripe-openapi[bot] Feb 12, 2025
c3d86db
Update generated code for v1490
stripe-openapi[bot] Feb 13, 2025
2e28d12
Update generated code for v1491
stripe-openapi[bot] Feb 13, 2025
9c87cb3
Update generated code for v1493
stripe-openapi[bot] Feb 14, 2025
f4b0a64
Update generated code for v1494
stripe-openapi[bot] Feb 14, 2025
65ac537
Update generated code for v1495
stripe-openapi[bot] Feb 14, 2025
1f38f65
Update generated code for v1495
stripe-openapi[bot] Feb 14, 2025
11912a0
Update generated code for v1496
stripe-openapi[bot] Feb 19, 2025
bc58812
Update generated code for v1501
stripe-openapi[bot] Feb 20, 2025
c2bdef6
Update generated code for v1501
stripe-openapi[bot] Feb 21, 2025
baeaf84
Update generated code for v1502
stripe-openapi[bot] Feb 21, 2025
240505a
Update generated code for v1504
stripe-openapi[bot] Feb 24, 2025
d9c6001
Update generated code for v1505
stripe-openapi[bot] Feb 24, 2025
d7ce0c6
Update generated code for v1505
stripe-openapi[bot] Feb 24, 2025
f395139
Update generated code (#2256)
stripe-openapi[bot] Feb 24, 2025
4b95f81
Bump version to 17.7.0
prathmesh-stripe Feb 24, 2025
2b60bf0
Merge upstream and update generated code for v1506
stripe-openapi[bot] Feb 25, 2025
0fe3d18
Update generated code for v1507
stripe-openapi[bot] Feb 25, 2025
707abe6
Update generated code for v1508
stripe-openapi[bot] Feb 25, 2025
7a466c8
Update generated code for v1510
stripe-openapi[bot] Feb 26, 2025
800703b
Update generated code for v1511
stripe-openapi[bot] Feb 27, 2025
da9bc5f
Update generated code for v1512
stripe-openapi[bot] Feb 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 17.7.0 - 2025-02-24
* [#2256](https://github.com/stripe/stripe-node/pull/2256) Update generated code
* Add support for `prices` on `Billing.CreditBalanceSummaryRetrieveParams.filter.applicability_scope`, `Billing.CreditGrant.applicability_config.scope`, and `Billing.CreditGrantCreateParams.applicability_config.scope`
* Change `Billing.CreditBalanceSummaryRetrieveParams.filter.applicability_scope.price_type`, `Billing.CreditGrant.applicability_config.scope.price_type`, and `Billing.CreditGrantCreateParams.applicability_config.scope.price_type` to be optional
* Add support for `priority` on `Billing.CreditGrantCreateParams` and `Billing.CreditGrant`
* Add support for `target_date` on `Checkout.Session.payment_method_options.acss_debit`, `Checkout.Session.payment_method_options.au_becs_debit`, `Checkout.Session.payment_method_options.bacs_debit`, `Checkout.Session.payment_method_options.sepa_debit`, `Checkout.Session.payment_method_options.us_bank_account`, `Checkout.SessionCreateParams.payment_method_options.acss_debit`, `Checkout.SessionCreateParams.payment_method_options.au_becs_debit`, `Checkout.SessionCreateParams.payment_method_options.bacs_debit`, `Checkout.SessionCreateParams.payment_method_options.sepa_debit`, `Checkout.SessionCreateParams.payment_method_options.us_bank_account`, `PaymentIntent.payment_method_options.acss_debit`, `PaymentIntent.payment_method_options.au_becs_debit`, `PaymentIntent.payment_method_options.bacs_debit`, `PaymentIntent.payment_method_options.sepa_debit`, `PaymentIntent.payment_method_options.us_bank_account`, `PaymentIntentConfirmParams.payment_method_options.acss_debit`, `PaymentIntentConfirmParams.payment_method_options.au_becs_debit`, `PaymentIntentConfirmParams.payment_method_options.bacs_debit`, `PaymentIntentConfirmParams.payment_method_options.sepa_debit`, `PaymentIntentConfirmParams.payment_method_options.us_bank_account`, `PaymentIntentCreateParams.payment_method_options.acss_debit`, `PaymentIntentCreateParams.payment_method_options.au_becs_debit`, `PaymentIntentCreateParams.payment_method_options.bacs_debit`, `PaymentIntentCreateParams.payment_method_options.sepa_debit`, `PaymentIntentCreateParams.payment_method_options.us_bank_account`, `PaymentIntentUpdateParams.payment_method_options.acss_debit`, `PaymentIntentUpdateParams.payment_method_options.au_becs_debit`, `PaymentIntentUpdateParams.payment_method_options.bacs_debit`, `PaymentIntentUpdateParams.payment_method_options.sepa_debit`, and `PaymentIntentUpdateParams.payment_method_options.us_bank_account`
* Add support for `restrictions` on `Checkout.Session.payment_method_options.card` and `Checkout.SessionCreateParams.payment_method_options.card`
* Add support for `collected_information` on `Checkout.SessionUpdateParams` and `Checkout.Session`
* Change `Checkout.Session.discounts`, `Refund.destination_details.blik.network_decline_code`, and `Refund.destination_details.swish.network_decline_code` to be required
* Add support for `metadata` on `ProductCreateParams.default_price_data`
* Change type of `TokenCreateParams.person.political_exposure` from `string` to `enum('existing'|'none')`
* Add support for new value `2025-02-24.acacia` on enum `WebhookEndpointCreateParams.api_version`
* [#2259](https://github.com/stripe/stripe-node/pull/2259) Add Next.js App Router webhook example that leverages Route Handlers
* [#2257](https://github.com/stripe/stripe-node/pull/2257) Include `OPENAPI_VERSION` into npm bundle

## 17.7.0-beta.1 - 2025-02-07
* [#2254](https://github.com/stripe/stripe-node/pull/2254) Update generated code for beta
* Add support for `rejected_reason` on `Account.risk_controls`
Expand Down
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1472
v1512
69 changes: 69 additions & 0 deletions examples/webhook-signing/nextjs/app/api/webhooks/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import {Stripe} from 'stripe';
import {NextResponse} from 'next/server';
import {headers} from 'next/headers';

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY as string);

export async function POST(req: Request) {
let event: Stripe.Event;

try {
const stripeSignature = (await headers()).get('stripe-signature');

event = stripe.webhooks.constructEvent(
await req.text(),
stripeSignature as string,
process.env.STRIPE_WEBHOOK_SECRET as string
);
} catch (err) {
const errorMessage = err instanceof Error ? err.message : 'Unknown error';
// On error, log and return the error message.
if (err! instanceof Error) console.log(err);
console.log(`❌ Error message: ${errorMessage}`);
return NextResponse.json(
{message: `Webhook Error: ${errorMessage}`},
{status: 400}
);
}

// Successfully constructed event.
console.log('✅ Success:', event.id);

const permittedEvents: string[] = [
'checkout.session.completed',
'payment_intent.succeeded',
'payment_intent.payment_failed',
];

if (permittedEvents.includes(event.type)) {
let data;

try {
switch (event.type) {
case 'checkout.session.completed':
data = event.data.object as Stripe.Checkout.Session;
console.log(`💰 CheckoutSession status: ${data.payment_status}`);
break;
case 'payment_intent.payment_failed':
data = event.data.object as Stripe.PaymentIntent;
console.log(`❌ Payment failed: ${data.last_payment_error?.message}`);
break;
case 'payment_intent.succeeded':
data = event.data.object as Stripe.PaymentIntent;
console.log(`💰 PaymentIntent status: ${data.status}`);
break;
default:
throw new Error(`Unhandled event: ${event.type}`);
}
} catch (error) {
console.log(error);
return NextResponse.json(
{message: 'Webhook handler failed'},
{status: 500}
);
}
}

// Return a response to acknowledge receipt of the event.
return NextResponse.json({message: 'Received'}, {status: 200});
}
2 changes: 1 addition & 1 deletion src/apiVersion.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// File generated from our OpenAPI spec

export const ApiVersion = '2025-01-27.acacia';
export const ApiVersion = '2025-03-31.basil';
10 changes: 10 additions & 0 deletions src/resources/TestHelpers/Terminal/Readers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,14 @@ export const Readers = StripeResource.extend({
fullPath:
'/v1/test_helpers/terminal/readers/{reader}/present_payment_method',
}),
succeedInputCollection: stripeMethod({
method: 'POST',
fullPath:
'/v1/test_helpers/terminal/readers/{reader}/succeed_input_collection',
}),
timeoutInputCollection: stripeMethod({
method: 'POST',
fullPath:
'/v1/test_helpers/terminal/readers/{reader}/timeout_input_collection',
}),
});
2 changes: 1 addition & 1 deletion types/Accounts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ declare module 'stripe' {
/**
* Represents the rejected reason of the account. Empty if account is not rejected, or rejected by Stripe. Please see [this page for more details](https://stripe.com/docs/connect/)
*/
rejected_reason?: RiskControls.RejectedReason;
rejected_reason?: RiskControls.RejectedReason | null;
}

namespace RiskControls {
Expand Down
8 changes: 2 additions & 6 deletions types/AccountsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4157,7 +4157,7 @@ declare module 'stripe' {
/**
* Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction.
*/
political_exposure?: AccountCreatePersonParams.PoliticalExposure;
political_exposure?: string;

/**
* The person's registered address.
Expand Down Expand Up @@ -4264,8 +4264,6 @@ declare module 'stripe' {
}
}

type PoliticalExposure = 'existing' | 'none';

interface Relationship {
/**
* Whether the person is the authorizer of the account's representative.
Expand Down Expand Up @@ -4699,7 +4697,7 @@ declare module 'stripe' {
/**
* Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction.
*/
political_exposure?: AccountUpdatePersonParams.PoliticalExposure;
political_exposure?: string;

/**
* The person's registered address.
Expand Down Expand Up @@ -4806,8 +4804,6 @@ declare module 'stripe' {
}
}

type PoliticalExposure = 'existing' | 'none';

interface Relationship {
/**
* Whether the person is the authorizer of the account's representative.
Expand Down
2 changes: 1 addition & 1 deletion types/Billing/CreditBalanceSummaryResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ declare module 'stripe' {
/**
* The price type that credit grants can apply to. We currently only support the `metered` price type.
*/
price_type: 'metered';
price_type?: 'metered';

/**
* A list of prices that the credit grant can apply to. We currently only support the `metered` prices.
Expand Down
5 changes: 5 additions & 0 deletions types/Billing/CreditGrants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ declare module 'stripe' {
*/
name: string | null;

/**
* The priority for applying this credit grant. The highest priority is 0 and the lowest is 100.
*/
priority?: number | null;

/**
* ID of the test clock this credit grant belongs to.
*/
Expand Down
9 changes: 7 additions & 2 deletions types/Billing/CreditGrantsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ declare module 'stripe' {
amount: CreditGrantCreateParams.Amount;

/**
* Configuration specifying what this credit grant applies to.
* Configuration specifying what this credit grant applies to. We currently only support `metered` prices that have a [Billing Meter](https://docs.stripe.com/api/billing/meter) attached to them.
*/
applicability_config: CreditGrantCreateParams.ApplicabilityConfig;

Expand Down Expand Up @@ -48,6 +48,11 @@ declare module 'stripe' {
* A descriptive name shown in the Dashboard.
*/
name?: string;

/**
* The desired priority for applying this credit grant. If not specified, it will be set to the default value of 50. The highest priority is 0 and the lowest is 100.
*/
priority?: number;
}

namespace CreditGrantCreateParams {
Expand Down Expand Up @@ -89,7 +94,7 @@ declare module 'stripe' {
/**
* The price type that credit grants can apply to. We currently only support the `metered` price type.
*/
price_type: 'metered';
price_type?: 'metered';

/**
* A list of prices that the credit grant can apply to. We currently only support the `metered` prices.
Expand Down
2 changes: 1 addition & 1 deletion types/Charges.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ declare module 'stripe' {
twint?: PaymentMethodDetails.Twint;

/**
* The type of transaction-specific details of the payment method used in the payment, one of `ach_credit_transfer`, `ach_debit`, `acss_debit`, `alipay`, `au_becs_debit`, `bancontact`, `card`, `card_present`, `eps`, `giropay`, `ideal`, `klarna`, `multibanco`, `p24`, `sepa_debit`, `sofort`, `stripe_account`, or `wechat`.
* The type of transaction-specific details of the payment method used in the payment. See [PaymentMethod.type](https://stripe.com/docs/api/payment_methods/object#payment_method_object-type) for the full list of possible types.
* An additional hash is included on `payment_method_details` with a name matching this value.
* It contains information specific to the payment method.
*/
Expand Down
50 changes: 30 additions & 20 deletions types/Checkout/Sessions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ declare module 'stripe' {
/**
* Information about the customer collected within the Checkout Session.
*/
collected_information?: Session.CollectedInformation | null;
collected_information: Session.CollectedInformation | null;

/**
* Results of `consent_collection` for this session.
Expand Down Expand Up @@ -421,7 +421,7 @@ declare module 'stripe' {
/**
* Shipping information for this Checkout Session.
*/
shipping_details?: CollectedInformation.ShippingDetails | null;
shipping_details: CollectedInformation.ShippingDetails | null;

/**
* Customer's tax ids for this Checkout Session.
Expand All @@ -431,27 +431,12 @@ declare module 'stripe' {

namespace CollectedInformation {
interface ShippingDetails {
address?: Stripe.Address;
address: Stripe.Address;

/**
* The delivery service that shipped a physical product, such as Fedex, UPS, USPS, etc.
* Customer name.
*/
carrier?: string | null;

/**
* Recipient name.
*/
name?: string;

/**
* Recipient phone (including extension).
*/
phone?: string | null;

/**
* The tracking number for a physical product, obtained from the delivery service. If multiple tracking numbers were generated for this purchase, please separate them with commas.
*/
tracking_number?: string | null;
name: string;
}

interface TaxId {
Expand Down Expand Up @@ -1229,6 +1214,11 @@ declare module 'stripe' {
*/
setup_future_usage?: AcssDebit.SetupFutureUsage;

/**
* Controls when Stripe will attempt to debit the funds from the customer's account. The date must be a string in YYYY-MM-DD format. The date must be in the future and between 3 and 15 calendar days from now.
*/
target_date?: string;

/**
* Bank account verification method.
*/
Expand Down Expand Up @@ -1345,6 +1335,11 @@ declare module 'stripe' {
* When processing card payments, Stripe uses `setup_future_usage` to help you comply with regional legislation and network rules, such as [SCA](https://stripe.com/strong-customer-authentication).
*/
setup_future_usage?: 'none';

/**
* Controls when Stripe will attempt to debit the funds from the customer's account. The date must be a string in YYYY-MM-DD format. The date must be in the future and between 3 and 15 calendar days from now.
*/
target_date?: string;
}

interface BacsDebit {
Expand All @@ -1360,6 +1355,11 @@ declare module 'stripe' {
* When processing card payments, Stripe uses `setup_future_usage` to help you comply with regional legislation and network rules, such as [SCA](https://stripe.com/strong-customer-authentication).
*/
setup_future_usage?: BacsDebit.SetupFutureUsage;

/**
* Controls when Stripe will attempt to debit the funds from the customer's account. The date must be a string in YYYY-MM-DD format. The date must be in the future and between 3 and 15 calendar days from now.
*/
target_date?: string;
}

namespace BacsDebit {
Expand Down Expand Up @@ -1994,6 +1994,11 @@ declare module 'stripe' {
* When processing card payments, Stripe uses `setup_future_usage` to help you comply with regional legislation and network rules, such as [SCA](https://stripe.com/strong-customer-authentication).
*/
setup_future_usage?: SepaDebit.SetupFutureUsage;

/**
* Controls when Stripe will attempt to debit the funds from the customer's account. The date must be a string in YYYY-MM-DD format. The date must be in the future and between 3 and 15 calendar days from now.
*/
target_date?: string;
}

namespace SepaDebit {
Expand Down Expand Up @@ -2041,6 +2046,11 @@ declare module 'stripe' {
*/
setup_future_usage?: UsBankAccount.SetupFutureUsage;

/**
* Controls when Stripe will attempt to debit the funds from the customer's account. The date must be a string in YYYY-MM-DD format. The date must be in the future and between 3 and 15 calendar days from now.
*/
target_date?: string;

/**
* Bank account verification method.
*/
Expand Down
27 changes: 26 additions & 1 deletion types/Checkout/SessionsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,11 @@ declare module 'stripe' {
*/
setup_future_usage?: AcssDebit.SetupFutureUsage;

/**
* Controls when Stripe will attempt to debit the funds from the customer's account. The date must be a string in YYYY-MM-DD format. The date must be in the future and between 3 and 15 calendar days from now.
*/
target_date?: string;

/**
* Verification method for the intent
*/
Expand Down Expand Up @@ -1351,6 +1356,11 @@ declare module 'stripe' {
* When processing card payments, Stripe uses `setup_future_usage` to help you comply with regional legislation and network rules, such as [SCA](https://stripe.com/strong-customer-authentication).
*/
setup_future_usage?: 'none';

/**
* Controls when Stripe will attempt to debit the funds from the customer's account. The date must be a string in YYYY-MM-DD format. The date must be in the future and between 3 and 15 calendar days from now.
*/
target_date?: string;
}

interface BacsDebit {
Expand All @@ -1369,6 +1379,11 @@ declare module 'stripe' {
* When processing card payments, Stripe uses `setup_future_usage` to help you comply with regional legislation and network rules, such as [SCA](https://stripe.com/strong-customer-authentication).
*/
setup_future_usage?: BacsDebit.SetupFutureUsage;

/**
* Controls when Stripe will attempt to debit the funds from the customer's account. The date must be a string in YYYY-MM-DD format. The date must be in the future and between 3 and 15 calendar days from now.
*/
target_date?: string;
}

namespace BacsDebit {
Expand Down Expand Up @@ -2075,6 +2090,11 @@ declare module 'stripe' {
* When processing card payments, Stripe uses `setup_future_usage` to help you comply with regional legislation and network rules, such as [SCA](https://stripe.com/strong-customer-authentication).
*/
setup_future_usage?: SepaDebit.SetupFutureUsage;

/**
* Controls when Stripe will attempt to debit the funds from the customer's account. The date must be a string in YYYY-MM-DD format. The date must be in the future and between 3 and 15 calendar days from now.
*/
target_date?: string;
}

namespace SepaDebit {
Expand Down Expand Up @@ -2125,6 +2145,11 @@ declare module 'stripe' {
*/
setup_future_usage?: UsBankAccount.SetupFutureUsage;

/**
* Controls when Stripe will attempt to debit the funds from the customer's account. The date must be a string in YYYY-MM-DD format. The date must be in the future and between 3 and 15 calendar days from now.
*/
target_date?: string;

/**
* Verification method for the intent
*/
Expand Down Expand Up @@ -2892,7 +2917,7 @@ declare module 'stripe' {
*
* To update an existing line item, specify its `id` along with the new values of the fields to update.
*
* To add a new line item, specify a `price` and `quantity`. We don't currently support recurring prices.
* To add a new line item, specify a `price` and `quantity`.
*
* To remove an existing line item, omit the line item's ID from the retransmitted array.
*
Expand Down
Loading
Loading