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

Where params are union of types, merge the types instead of having numbered suffixes in type names #2111

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
50 changes: 6 additions & 44 deletions types/PaymentIntentsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4871,10 +4871,7 @@ declare module 'stripe' {
*/
mandate?: string;

mandate_data?: Stripe.Emptyable<
| PaymentIntentConfirmParams.MandateData1
| PaymentIntentConfirmParams.MandateData2
>;
mandate_data?: Stripe.Emptyable<PaymentIntentConfirmParams.MandateData>;

/**
* Set to `true` to indicate that the customer isn't in your checkout flow during this payment attempt and can't authenticate. Use this parameter in scenarios where you collect card details and [charge them later](https://stripe.com/docs/payments/cards/charging-saved-cards).
Expand Down Expand Up @@ -4947,14 +4944,14 @@ declare module 'stripe' {
namespace PaymentIntentConfirmParams {
type CaptureMethod = 'automatic' | 'automatic_async' | 'manual';

interface MandateData1 {
interface MandateData {
/**
* This hash contains details about the customer acceptance of the Mandate.
*/
customer_acceptance: MandateData1.CustomerAcceptance;
customer_acceptance?: MandateData.CustomerAcceptance;
}

namespace MandateData1 {
namespace MandateData {
interface CustomerAcceptance {
/**
* The time at which the customer accepted the Mandate.
Expand All @@ -4980,43 +4977,6 @@ declare module 'stripe' {
namespace CustomerAcceptance {
interface Offline {}

interface Online {
/**
* The IP address from which the Mandate was accepted by the customer.
*/
ip_address: string;

/**
* The user agent of the browser from which the Mandate was accepted by the customer.
*/
user_agent: string;
}

type Type = 'offline' | 'online';
}
}

interface MandateData2 {
/**
* This hash contains details about the customer acceptance of the Mandate.
*/
customer_acceptance: MandateData2.CustomerAcceptance;
}

namespace MandateData2 {
interface CustomerAcceptance {
/**
* If this is a Mandate accepted online, this hash contains details about the online acceptance.
*/
online: CustomerAcceptance.Online;

/**
* The type of customer acceptance information included with the Mandate.
*/
type: 'online';
}

namespace CustomerAcceptance {
interface Online {
/**
* The IP address from which the Mandate was accepted by the customer.
Expand All @@ -5028,6 +4988,8 @@ declare module 'stripe' {
*/
user_agent?: string;
}

type Type = 'offline' | 'online';
}
}

Expand Down
26 changes: 12 additions & 14 deletions types/PaymentMethodsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ declare module 'stripe' {
/**
* If this is a `card` PaymentMethod, this hash contains the user's card details. For backwards compatibility, you can alternatively provide a Stripe token (e.g., for Apple Pay, Amex Express Checkout, or legacy Checkout) into the card hash with format `card: {token: "tok_visa"}`. When providing a card number, you must meet the requirements for [PCI compliance](https://stripe.com/docs/security#validating-pci-compliance). We strongly recommend using Stripe.js instead of interacting with this API directly.
*/
card?: PaymentMethodCreateParams.Card1 | PaymentMethodCreateParams.Card2;
card?: PaymentMethodCreateParams.Card;

/**
* If this is a `cashapp` PaymentMethod, this hash contains details about the Cash App Pay payment method.
Expand Down Expand Up @@ -319,7 +319,7 @@ declare module 'stripe' {
tax_id: string;
}

interface Card1 {
interface Card {
/**
* The card's CVC. It is highly recommended to always include this value.
*/
Expand All @@ -328,25 +328,30 @@ declare module 'stripe' {
/**
* Two-digit number representing the card's expiration month.
*/
exp_month: number;
exp_month?: number;

/**
* Four-digit number representing the card's expiration year.
*/
exp_year: number;
exp_year?: number;

/**
* Contains information about card networks used to process the payment.
*/
networks?: Card1.Networks;
networks?: Card.Networks;

/**
* The card number, as a string without any separators.
*/
number: string;
number?: string;

/**
* For backwards compatibility, you can alternatively provide a Stripe token (e.g., for Apple Pay, Amex Express Checkout, or legacy Checkout) into the card hash with format card: {token: "tok_visa"}.
*/
token?: string;
}

namespace Card1 {
namespace Card {
interface Networks {
/**
* The customer's preferred card network for co-branded cards. Supports `cartes_bancaires`, `mastercard`, or `visa`. Selection of a network that does not apply to the card will be stored as `invalid_preference` on the card.
Expand All @@ -359,13 +364,6 @@ declare module 'stripe' {
}
}

interface Card2 {
/**
* For backwards compatibility, you can alternatively provide a Stripe token (e.g., for Apple Pay, Amex Express Checkout, or legacy Checkout) into the card hash with format card: {token: "tok_visa"}.
*/
token: string;
}

interface Cashapp {}

interface CustomerBalance {}
Expand Down
50 changes: 6 additions & 44 deletions types/SetupIntentsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2339,10 +2339,7 @@ declare module 'stripe' {
*/
expand?: Array<string>;

mandate_data?: Stripe.Emptyable<
| SetupIntentConfirmParams.MandateData1
| SetupIntentConfirmParams.MandateData2
>;
mandate_data?: Stripe.Emptyable<SetupIntentConfirmParams.MandateData>;

/**
* ID of the payment method (a PaymentMethod, Card, or saved Source object) to attach to this SetupIntent.
Expand Down Expand Up @@ -2374,14 +2371,14 @@ declare module 'stripe' {
}

namespace SetupIntentConfirmParams {
interface MandateData1 {
interface MandateData {
/**
* This hash contains details about the customer acceptance of the Mandate.
*/
customer_acceptance: MandateData1.CustomerAcceptance;
customer_acceptance?: MandateData.CustomerAcceptance;
}

namespace MandateData1 {
namespace MandateData {
interface CustomerAcceptance {
/**
* The time at which the customer accepted the Mandate.
Expand All @@ -2407,43 +2404,6 @@ declare module 'stripe' {
namespace CustomerAcceptance {
interface Offline {}

interface Online {
/**
* The IP address from which the Mandate was accepted by the customer.
*/
ip_address: string;

/**
* The user agent of the browser from which the Mandate was accepted by the customer.
*/
user_agent: string;
}

type Type = 'offline' | 'online';
}
}

interface MandateData2 {
/**
* This hash contains details about the customer acceptance of the Mandate.
*/
customer_acceptance: MandateData2.CustomerAcceptance;
}

namespace MandateData2 {
interface CustomerAcceptance {
/**
* If this is a Mandate accepted online, this hash contains details about the online acceptance.
*/
online: CustomerAcceptance.Online;

/**
* The type of customer acceptance information included with the Mandate.
*/
type: 'online';
}

namespace CustomerAcceptance {
interface Online {
/**
* The IP address from which the Mandate was accepted by the customer.
Expand All @@ -2455,6 +2415,8 @@ declare module 'stripe' {
*/
user_agent?: string;
}

type Type = 'offline' | 'online';
}
}

Expand Down
Loading