Skip to content

Commit f153c9b

Browse files
fix: align types to rfc
1 parent 7464de9 commit f153c9b

File tree

3 files changed

+63
-7
lines changed

3 files changed

+63
-7
lines changed

modules/@shopify/checkout-sheet-kit/src/components/Checkout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import type {
3030
CheckoutAddressChangeStart,
3131
CheckoutCompleteEvent,
3232
CheckoutException,
33+
CheckoutPaymentMethodChangeStart,
3334
CheckoutStartEvent,
3435
} from '..';
3536
import {useCheckoutEvents} from '../CheckoutEventProvider';

modules/@shopify/checkout-sheet-kit/src/events.d.ts

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,18 +531,69 @@ export interface CheckoutAddressChangeStartResponse {
531531
errors?: CheckoutResponseError[];
532532
}
533533

534+
/**
535+
* Card brand identifiers for payment instruments.
536+
* Matches Storefront API card brand values.
537+
*/
538+
export type CardBrand =
539+
| 'VISA'
540+
| 'MASTERCARD'
541+
| 'AMERICAN_EXPRESS'
542+
| 'DISCOVER'
543+
| 'DINERS_CLUB'
544+
| 'JCB'
545+
| 'MAESTRO'
546+
| 'UNKNOWN';
547+
548+
/**
549+
* Expiry date for a payment instrument.
550+
*/
551+
export interface ExpiryInput {
552+
/** Month (1-12) */
553+
month: number;
554+
/** Four-digit year */
555+
year: number;
556+
}
557+
558+
/**
559+
* Display fields for a payment instrument shown to the buyer.
560+
*/
561+
export interface CartPaymentInstrumentDisplayInput {
562+
/** Last 4 digits of the card number */
563+
last4: string;
564+
/** Card brand (e.g., VISA, MASTERCARD) */
565+
brand: CardBrand;
566+
/** Name of the cardholder */
567+
cardHolderName: string;
568+
/** Card expiry date */
569+
expiry: ExpiryInput;
570+
}
571+
572+
/**
573+
* Input type for creating/updating payment instruments, aligned with Storefront API.
574+
* Display fields are grouped separately from the billing address.
575+
*
576+
* @see https://shopify.dev/docs/api/storefront/latest/input-objects/CartPaymentInstrumentInput
577+
*/
578+
export interface CartPaymentInstrumentInput {
579+
/** Unique identifier for this payment instrument */
580+
externalReference: string;
581+
/** Display information for the payment instrument */
582+
display: CartPaymentInstrumentDisplayInput;
583+
/** Billing address for the payment instrument */
584+
billingAddress: MailingAddressInput;
585+
}
586+
534587
/**
535588
* Event emitted when the buyer intends to change their payment method.
536589
*/
537-
/** Unique identifier for this event instance */
538590
export interface CheckoutPaymentMethodChangeStart {
591+
/** Unique identifier for this event instance */
539592
id: string;
540593
/** Type of payment change event */
541-
type: string;
594+
type: 'paymentMethodChangeStart';
595+
/** Cart state with current payment instruments */
542596
cart?: {
543-
paymentInstruments?: Array<{
544-
type: string;
545-
details?: any;
546-
}>;
597+
paymentInstruments?: CartPaymentInstrumentInput[];
547598
};
548599
}

modules/@shopify/checkout-sheet-kit/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,11 +502,15 @@ export type {
502502
CartDeliveryAddressInput,
503503
CartDeliveryInput,
504504
CartInput,
505+
CardBrand,
506+
CartPaymentInstrumentDisplayInput,
507+
CartPaymentInstrumentInput,
505508
CheckoutAddressChangeStart,
506509
CheckoutAddressChangeStartResponse,
507510
CheckoutCompleteEvent,
508-
CheckoutPaymentChangeIntent,
511+
CheckoutPaymentMethodChangeStart,
509512
CheckoutResponseError,
513+
ExpiryInput,
510514
CheckoutStartEvent,
511515
MailingAddressInput,
512516
} from './events.d';

0 commit comments

Comments
 (0)