Skip to content

Commit

Permalink
Merge branch 'master' into sdk-release/next-major
Browse files Browse the repository at this point in the history
  • Loading branch information
anniel-stripe authored Aug 7, 2023
2 parents 0dbeb2a + 3bab5d9 commit 2f644e5
Show file tree
Hide file tree
Showing 52 changed files with 312 additions and 208 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 12.17.0 - 2023-08-03
* [#1863](https://github.com/stripe/stripe-node/pull/1863) Update generated code
* Change type of `AccountCreateParams.settings.card_issuing.tos_acceptance.user_agent`, `AccountCreateParams.settings.treasury.tos_acceptance.user_agent`, `AccountUpdateParams.settings.card_issuing.tos_acceptance.user_agent`, `AccountUpdateParams.settings.treasury.tos_acceptance.user_agent`, `BillingPortal.ConfigurationCreateParams.business_profile.headline`, `BillingPortal.ConfigurationUpdateParams.business_profile.headline`, `InvoiceCreateParams.payment_settings.default_mandate`, `InvoiceCreateParams.shipping_details.phone`, `InvoicePayParams.mandate`, `InvoiceUpdateParams.default_source`, `InvoiceUpdateParams.payment_settings.default_mandate`, `InvoiceUpdateParams.shipping_details.phone`, `Issuing.CardholderCreateParams.individual.card_issuing.user_terms_acceptance.user_agent`, `Issuing.CardholderUpdateParams.individual.card_issuing.user_terms_acceptance.user_agent`, `Issuing.DisputeCreateParams.evidence.canceled.cancellation_reason`, `Issuing.DisputeCreateParams.evidence.canceled.explanation`, `Issuing.DisputeCreateParams.evidence.canceled.product_description`, `Issuing.DisputeCreateParams.evidence.duplicate.explanation`, `Issuing.DisputeCreateParams.evidence.fraudulent.explanation`, `Issuing.DisputeCreateParams.evidence.merchandise_not_as_described.explanation`, `Issuing.DisputeCreateParams.evidence.merchandise_not_as_described.return_description`, `Issuing.DisputeCreateParams.evidence.not_received.explanation`, `Issuing.DisputeCreateParams.evidence.not_received.product_description`, `Issuing.DisputeCreateParams.evidence.other.explanation`, `Issuing.DisputeCreateParams.evidence.other.product_description`, `Issuing.DisputeCreateParams.evidence.service_not_as_described.cancellation_reason`, `Issuing.DisputeCreateParams.evidence.service_not_as_described.explanation`, `Issuing.DisputeUpdateParams.evidence.canceled.cancellation_reason`, `Issuing.DisputeUpdateParams.evidence.canceled.explanation`, `Issuing.DisputeUpdateParams.evidence.canceled.product_description`, `Issuing.DisputeUpdateParams.evidence.duplicate.explanation`, `Issuing.DisputeUpdateParams.evidence.fraudulent.explanation`, `Issuing.DisputeUpdateParams.evidence.merchandise_not_as_described.explanation`, `Issuing.DisputeUpdateParams.evidence.merchandise_not_as_described.return_description`, `Issuing.DisputeUpdateParams.evidence.not_received.explanation`, `Issuing.DisputeUpdateParams.evidence.not_received.product_description`, `Issuing.DisputeUpdateParams.evidence.other.explanation`, `Issuing.DisputeUpdateParams.evidence.other.product_description`, `Issuing.DisputeUpdateParams.evidence.service_not_as_described.cancellation_reason`, `Issuing.DisputeUpdateParams.evidence.service_not_as_described.explanation`, `PaymentIntentConfirmParams.payment_method_data.billing_details.name`, `PaymentIntentConfirmParams.payment_method_data.billing_details.phone`, `PaymentIntentConfirmParams.payment_method_options.konbini.confirmation_number`, `PaymentIntentConfirmParams.payment_method_options.konbini.product_description`, `PaymentIntentCreateParams.payment_method_data.billing_details.name`, `PaymentIntentCreateParams.payment_method_data.billing_details.phone`, `PaymentIntentCreateParams.payment_method_options.konbini.confirmation_number`, `PaymentIntentCreateParams.payment_method_options.konbini.product_description`, `PaymentIntentUpdateParams.payment_method_data.billing_details.name`, `PaymentIntentUpdateParams.payment_method_data.billing_details.phone`, `PaymentIntentUpdateParams.payment_method_options.konbini.confirmation_number`, `PaymentIntentUpdateParams.payment_method_options.konbini.product_description`, `PaymentMethodCreateParams.billing_details.name`, `PaymentMethodCreateParams.billing_details.phone`, `PaymentMethodUpdateParams.billing_details.name`, `PaymentMethodUpdateParams.billing_details.phone`, `ProductUpdateParams.caption`, `ProductUpdateParams.description`, `ProductUpdateParams.unit_label`, `QuoteCreateParams.description`, `QuoteCreateParams.footer`, `QuoteCreateParams.header`, `QuoteUpdateParams.description`, `QuoteUpdateParams.footer`, `QuoteUpdateParams.header`, `QuoteUpdateParams.subscription_data.description`, `SetupIntentConfirmParams.payment_method_data.billing_details.name`, `SetupIntentConfirmParams.payment_method_data.billing_details.phone`, `SetupIntentCreateParams.payment_method_data.billing_details.name`, `SetupIntentCreateParams.payment_method_data.billing_details.phone`, `SetupIntentUpdateParams.payment_method_data.billing_details.name`, `SetupIntentUpdateParams.payment_method_data.billing_details.phone`, `SubscriptionCancelParams.cancellation_details.comment`, `SubscriptionScheduleCreateParams.default_settings.description`, `SubscriptionScheduleCreateParams.phases[].description`, `SubscriptionScheduleUpdateParams.default_settings.description`, `SubscriptionScheduleUpdateParams.phases[].description`, `SubscriptionUpdateParams.cancellation_details.comment`, `SubscriptionUpdateParams.default_source`, `SubscriptionUpdateParams.description`, `Tax.CalculationCreateParams.customer_details.address.city`, `Tax.CalculationCreateParams.customer_details.address.line1`, `Tax.CalculationCreateParams.customer_details.address.line2`, `Tax.CalculationCreateParams.customer_details.address.postal_code`, `Tax.CalculationCreateParams.customer_details.address.state`, `Terminal.LocationUpdateParams.configuration_overrides`, `Terminal.ReaderUpdateParams.label`, `TokenCreateParams.person.documents.company_authorization.files[]`, `TokenCreateParams.person.documents.passport.files[]`, `TokenCreateParams.person.documents.visa.files[]`, `Treasury.OutboundPaymentCreateParams.destination_payment_method_data.billing_details.name`, `Treasury.OutboundPaymentCreateParams.destination_payment_method_data.billing_details.phone`, `WebhookEndpointCreateParams.description`, and `WebhookEndpointUpdateParams.description` from `string` to `emptyStringable(string)`
* Add support for `subscription_details` on `Invoice`
* Add support for `preferred_settlement_speed` on `PaymentIntent.payment_method_options.us_bank_account`, `PaymentIntentConfirmParams.payment_method_options.us_bank_account`, `PaymentIntentCreateParams.payment_method_options.us_bank_account`, and `PaymentIntentUpdateParams.payment_method_options.us_bank_account`
* Add support for new values `sepa_debit_fingerprint` and `us_bank_account_fingerprint` on enums `Radar.ValueList.item_type` and `Radar.ValueListCreateParams.item_type`
* [#1866](https://github.com/stripe/stripe-node/pull/1866) Allow monkey patching http / https

## 12.16.0 - 2023-07-27
* [#1853](https://github.com/stripe/stripe-node/pull/1853) Update generated code
* Add support for `monthly_estimated_revenue` on `Account.business_profile`, `AccountCreateParams.business_profile`, and `AccountUpdateParams.business_profile`
Expand Down
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v433
v446
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.16.0
12.17.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stripe",
"version": "12.16.0",
"version": "12.17.0",
"description": "Stripe API wrapper",
"keywords": [
"stripe",
Expand Down
26 changes: 18 additions & 8 deletions src/net/NodeHttpClient.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import * as http from 'http';
import * as https from 'https';
import * as http_ from 'http';
import * as https_ from 'https';
import {RequestHeaders, RequestData} from '../Types.js';
import {
HttpClient,
HttpClientResponse,
HttpClientResponseInterface,
} from './HttpClient.js';

// `import * as http_ from 'http'` creates a "Module Namespace Exotic Object"
// which is immune to monkey-patching, whereas http_.default (in an ES Module context)
// will resolve to the same thing as require('http'), which is
// monkey-patchable. We care about this because users in their test
// suites might be using a library like "nock" which relies on the ability
// to monkey-patch and intercept calls to http.request.
const http = ((http_ as unknown) as {default: typeof http_}).default || http_;
const https =
((https_ as unknown) as {default: typeof https_}).default || https_;

const defaultHttpAgent = new http.Agent({keepAlive: true});
const defaultHttpsAgent = new https.Agent({keepAlive: true});

Expand All @@ -15,9 +25,9 @@ const defaultHttpsAgent = new https.Agent({keepAlive: true});
* requests.`
*/
export class NodeHttpClient extends HttpClient {
_agent?: http.Agent | https.Agent | undefined;
_agent?: http_.Agent | https_.Agent | undefined;

constructor(agent?: http.Agent | https.Agent) {
constructor(agent?: http_.Agent | https_.Agent) {
super();
this._agent = agent;
}
Expand Down Expand Up @@ -93,19 +103,19 @@ export class NodeHttpClient extends HttpClient {

export class NodeHttpClientResponse extends HttpClientResponse
implements HttpClientResponseInterface {
_res: http.IncomingMessage;
_res: http_.IncomingMessage;

constructor(res: http.IncomingMessage) {
constructor(res: http_.IncomingMessage) {
// @ts-ignore
super(res.statusCode, res.headers || {});
this._res = res;
}

getRawResponse(): http.IncomingMessage {
getRawResponse(): http_.IncomingMessage {
return this._res;
}

toStream(streamCompleteCallback: () => void): http.IncomingMessage {
toStream(streamCompleteCallback: () => void): http_.IncomingMessage {
// The raw response is itself the stream, so we just return that. To be
// backwards compatible, we should invoke the streamCompleteCallback only
// once the stream has been fully consumed.
Expand Down
2 changes: 1 addition & 1 deletion src/stripe.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function createStripe(
platformFunctions: PlatformFunctions,
requestSender: RequestSenderFactory = defaultRequestSenderFactory
): typeof Stripe {
Stripe.PACKAGE_VERSION = '12.16.0';
Stripe.PACKAGE_VERSION = '12.17.0';
Stripe.USER_AGENT = {
bindings_version: Stripe.PACKAGE_VERSION,
lang: 'node',
Expand Down
37 changes: 36 additions & 1 deletion testProjects/mjs/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import DefaultStripe, {Stripe} from 'stripe';
import assert from 'assert';
import * as http from 'http';

assert(Stripe.PACKAGE_VERSION);
assert(Stripe.USER_AGENT);
Expand Down Expand Up @@ -90,9 +91,43 @@ async function exampleFunction(args) {
}
}


// Test that http is monkey-patchable (motivation: https://github.com/stripe/stripe-node/issues/1844)
async function exampleMonkeyPatchFunction() {
http.default.request = () => {
throw new Error('foo');
};

try {
await stripe.paymentIntents.create({
currency: 'usd',
amount: 2000,
confirm: true,
payment_method: 'pm_card_visa',
});
} catch (e) {
assert (e instanceof stripe.errors.StripeConnectionError);
if (e.detail.message === 'foo') {
return;
} else {
throw e;
}
}

throw new Error('Expected an error');
}

exampleFunction({
// The required parameter currency is missing
amount: 2000,
confirm: true,
payment_method: 'pm_card_visa',
});
}).then(() => {
return exampleMonkeyPatchFunction()
}).then(() => {
process.exit(0);
}).catch((e) => {
console.error(e);
process.exit(1);
}
);
3 changes: 2 additions & 1 deletion tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"noImplicitThis": true,
"strict": true,
"strictFunctionTypes": true,
"types": [ "node" ]
"types": [ "node" ],
"esModuleInterop": false // This is a viral option, do not enable https://www.semver-ts.org/#module-interop
},
"include": ["./src/**/*"],
"exclude": ["./src/stripe.esm.node.ts", "./src/stripe.esm.worker.ts"],
Expand Down
8 changes: 4 additions & 4 deletions types/AccountsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ declare module 'stripe' {
/**
* The user agent of the browser from which the account representative accepted the service agreement.
*/
user_agent?: string;
user_agent?: Stripe.Emptyable<string>;
}
}

Expand Down Expand Up @@ -1255,7 +1255,7 @@ declare module 'stripe' {
/**
* The user agent of the browser from which the account representative accepted the service agreement.
*/
user_agent?: string;
user_agent?: Stripe.Emptyable<string>;
}
}
}
Expand Down Expand Up @@ -2365,7 +2365,7 @@ declare module 'stripe' {
/**
* The user agent of the browser from which the account representative accepted the service agreement.
*/
user_agent?: string;
user_agent?: Stripe.Emptyable<string>;
}
}

Expand Down Expand Up @@ -2498,7 +2498,7 @@ declare module 'stripe' {
/**
* The user agent of the browser from which the account representative accepted the service agreement.
*/
user_agent?: string;
user_agent?: Stripe.Emptyable<string>;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions types/ApplicationFees.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ declare module 'stripe' {
account: string | Stripe.Account;

/**
* Amount earned, in %s.
* Amount earned, in cents (or local equivalent).
*/
amount: number;

/**
* Amount in %s refunded (can be less than the amount attribute on the fee if a partial refund was issued)
* Amount in cents (or local equivalent) refunded (can be less than the amount attribute on the fee if a partial refund was issued)
*/
amount_refunded: number;

Expand Down
8 changes: 4 additions & 4 deletions types/BalanceTransactions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ declare module 'stripe' {
object: 'balance_transaction';

/**
* Gross amount of the transaction, in %s.
* Gross amount of the transaction, in cents (or local equivalent).
*/
amount: number;

Expand Down Expand Up @@ -50,17 +50,17 @@ declare module 'stripe' {
exchange_rate: number | null;

/**
* Fees (in %s) paid for this transaction.
* Fees (in cents (or local equivalent)) paid for this transaction.
*/
fee: number;

/**
* Detailed breakdown of fees (in %s) paid for this transaction.
* Detailed breakdown of fees (in cents (or local equivalent)) paid for this transaction.
*/
fee_details: Array<BalanceTransaction.FeeDetail>;

/**
* Net amount of the transaction, in %s.
* Net amount of the transaction, in cents (or local equivalent).
*/
net: number;

Expand Down
4 changes: 2 additions & 2 deletions types/BillingPortal/ConfigurationsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ declare module 'stripe' {
/**
* The messaging shown to customers in the portal.
*/
headline?: string;
headline?: Stripe.Emptyable<string>;

/**
* A link to the business's publicly available privacy policy.
Expand Down Expand Up @@ -289,7 +289,7 @@ declare module 'stripe' {
/**
* The messaging shown to customers in the portal.
*/
headline?: string;
headline?: Stripe.Emptyable<string>;

/**
* A link to the business's publicly available privacy policy.
Expand Down
4 changes: 2 additions & 2 deletions types/Charges.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ declare module 'stripe' {
amount: number;

/**
* Amount in %s captured (can be less than the amount attribute on the charge if a partial capture was made).
* Amount in cents (or local equivalent) captured (can be less than the amount attribute on the charge if a partial capture was made).
*/
amount_captured: number;

/**
* Amount in %s refunded (can be less than the amount attribute on the charge if a partial refund was issued).
* Amount in cents (or local equivalent) refunded (can be less than the amount attribute on the charge if a partial refund was issued).
*/
amount_refunded: number;

Expand Down
4 changes: 2 additions & 2 deletions types/Checkout/Sessions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ declare module 'stripe' {
taxability_reason: Tax.TaxabilityReason | null;

/**
* The amount on which tax is calculated, in %s.
* The amount on which tax is calculated, in cents (or local equivalent).
*/
taxable_amount: number | null;
}
Expand Down Expand Up @@ -1742,7 +1742,7 @@ declare module 'stripe' {
taxability_reason: Tax.TaxabilityReason | null;

/**
* The amount on which tax is calculated, in %s.
* The amount on which tax is calculated, in cents (or local equivalent).
*/
taxable_amount: number | null;
}
Expand Down
6 changes: 3 additions & 3 deletions types/Checkout/SessionsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2018,7 +2018,7 @@ declare module 'stripe' {

interface SubscriptionData {
/**
* A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner's Stripe account. To use an application fee percent, the request must be made on behalf of another account, using the `Stripe-Account` header or an OAuth key. For more information, see the application fees [documentation](https://stripe.com/docs/connect/subscriptions#collecting-fees-on-subscriptions).
* A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account. To use an application fee percent, the request must be made on behalf of another account, using the `Stripe-Account` header or an OAuth key. For more information, see the application fees [documentation](https://stripe.com/docs/connect/subscriptions#collecting-fees-on-subscriptions).
*/
application_fee_percent?: number;

Expand All @@ -2042,7 +2042,7 @@ declare module 'stripe' {
/**
* The subscription's description, meant to be displayable to the customer.
* Use this field to optionally store an explanation of the subscription
* for rendering in Stripe hosted surfaces.
* for rendering in the [customer portal](https://stripe.com/docs/customer-management).
*/
description?: string;

Expand Down Expand Up @@ -2095,7 +2095,7 @@ declare module 'stripe' {

interface TransferData {
/**
* A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the destination account. By default, the entire amount is transferred to the destination.
* A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the destination account. By default, the entire amount is transferred to the destination.
*/
amount_percent?: number;

Expand Down
2 changes: 1 addition & 1 deletion types/ConnectCollectionTransfers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ declare module 'stripe' {
object: 'connect_collection_transfer';

/**
* Amount transferred, in %s.
* Amount transferred, in cents (or local equivalent).
*/
amount: number;

Expand Down
2 changes: 1 addition & 1 deletion types/Coupons.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ declare module 'stripe' {
name: string | null;

/**
* Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon. For example, a coupon with percent_off of 50 will make a %s100 invoice %s50 instead.
* Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon. For example, a coupon with percent_off of 50 will make a $ (or local equivalent)100 invoice $ (or local equivalent)50 instead.
*/
percent_off: number | null;

Expand Down
Loading

0 comments on commit 2f644e5

Please sign in to comment.