Skip to content

Commit

Permalink
remove cart Element types (#587)
Browse files Browse the repository at this point in the history
  • Loading branch information
tylersmith-stripe committed Apr 2, 2024
1 parent 30e4293 commit 37ffe0e
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 381 deletions.
39 changes: 0 additions & 39 deletions tests/types/src/invalid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
StripeCardNumberElement,
StripeIbanElement,
StripePaymentElement,
StripeCartElement,
StripeExpressCheckoutElement,
StripeElementsOptions,
} from '../../../types';
Expand All @@ -15,7 +14,6 @@ declare const cardElement: StripeCardElement;
declare const cardNumberElement: StripeCardNumberElement;
declare const ibanElement: StripeIbanElement;
declare const paymentElement: StripePaymentElement;
declare const cartElement: StripeCartElement;
declare const expressCheckoutElement: StripeExpressCheckoutElement;

const options: StripeElementsOptions = {
Expand Down Expand Up @@ -96,40 +94,6 @@ paymentElement.on('change', (e) => {
}
});

// @ts-expect-error: either `product`, `price`, or `item_details` is required
cartElement.addLineItem({});

// @ts-expect-error: either `product`, `price`, or `item_details` is required
cartElement.addLineItem({quantity: 1});

// @ts-expect-error: only one of `product`, `price`, or `item_details` may be specified
cartElement.addLineItem({product: '', price: ''});

// @ts-expect-error: only one of `product`, `price`, or `item_details` may be specified
cartElement.addLineItem({
product: '',
item_details: {
external_id: '',
name: '',
unit_amount: 0,
},
});

// @ts-expect-error: `item_details.external_id` is required if `item_details` is present
cartElement.addLineItem({item_details: {name: '', unit_amount: 0}});

// @ts-expect-error: `item_details.name` is required if `item_details` is present
cartElement.addLineItem({item_details: {external_id: '', unit_amount: 0}});

// @ts-expect-error: `item_details.unit_amount` is required if `item_details` is present
cartElement.addLineItem({item_details: {external_id: '', name: ''}});

// @ts-expect-error: `clientSecret` is not updatable
cartElement.update({clientSecret: ''});

// @ts-expect-error: cartElement has no function `escape`
cartElement.escape();

expressCheckoutElement.update({
// @ts-expect-error: `wallets` option can't be updated
wallets: {
Expand Down Expand Up @@ -245,9 +209,6 @@ elements.create('issuingCardCopyButton', {
toCopy: 'non_existent',
});

// @ts-expect-error: CartElement requires a clientSecret
elements.create('cart');

// @ts-expect-error: `white-outline` is only supported by apple pay
elements.create('expressCheckout', {
buttonTheme: {
Expand Down
90 changes: 0 additions & 90 deletions tests/types/src/valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ import {
StripeShippingAddressElement,
StripeAddressElementChangeEvent,
StripeAddressElement,
StripeCartElementPayloadEvent,
StripeCartElementLineItemClickEvent,
StripeCartElement,
StripeElementType,
CanMakePaymentResult,
VerificationSession,
Expand Down Expand Up @@ -779,93 +776,6 @@ const retrievedShippingAddressElement: StripeShippingAddressElement | null = ele
'shippingAddress'
);

let cartElementDefaults: StripeCartElement = elements.create('cart', {
clientSecret: '',
});

const cartElement = elements.create('cart', {
clientSecret: '',
descriptor: 'cart',
header: {
text: 'cart',
},
showOnAdd: 'auto',
});

cartElement.show();

cartElement.hide();

cartElement.cancelCheckout();

cartElement.cancelCheckout('Error message');

cartElement.addLineItem({product: ''});

cartElement.addLineItem({price: ''});

cartElement.addLineItem({product: '', quantity: 1});

cartElement.addLineItem({price: '', quantity: 1});

cartElement.addLineItem({
item_details: {
external_id: '',
name: '',
unit_amount: 0,
},
quantity: 1,
});

cartElement.addLineItem({
item_details: {
external_id: '',
name: '',
unit_amount: 0,
image: '',
description: '',
},
quantity: 1,
});

cartElement.on('ready', (e: StripeCartElementPayloadEvent) => {
console.log(e.lineItems.count);
});

cartElement.on('lineitemclick', (e: StripeCartElementLineItemClickEvent) => {
e.preventDefault();
console.log(e.url);
});

cartElement.on('change', (e: StripeCartElementPayloadEvent) => {
console.log(e.lineItems.count);
});

cartElement.on('checkout', (e: StripeCartElementPayloadEvent) => {
console.log(e.lineItems.count);
});

cartElement.on(
'loaderror',
(e: {
elementType: 'cart';
error: {
type: string;
};
}) => {}
);

cartElement.update({
header: {
text: 'Your Cart',
},
showOnAdd: 'never',
});

const retrievedCartElement: StripeCartElement | null = elements.getElement(
'cart'
);

const expressCheckoutElementDefault = elements.create('expressCheckout');

const expressCheckoutElement = elements.create('expressCheckout', {
Expand Down
27 changes: 0 additions & 27 deletions types/stripe-js/elements-group.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import {
StripeCardNumberElementOptions,
StripeCardElement,
StripeCardElementOptions,
StripeCartElement,
StripeCartElementOptions,
StripeAuBankAccountElement,
StripeAfterpayClearpayMessageElementOptions,
StripeAffirmMessageElement,
Expand Down Expand Up @@ -234,29 +232,6 @@ export interface StripeElements {
*/
getElement(elementType: 'cardCvc'): StripeCardCvcElement | null;

/////////////////////////////
/// cart
/////////////////////////////

/**
* Requires beta access:
* Contact [Stripe support](https://support.stripe.com/) for more information.
*
* Creates a `CartElement`.
*/
create(
elementType: 'cart',
options: StripeCartElementOptions
): StripeCartElement;

/**
* Requires beta access:
* Contact [Stripe support](https://support.stripe.com/) for more information.
*
* Looks up a previously created `Element` by its type.
*/
getElement(elementType: 'cart'): StripeCartElement | null;

/////////////////////////////
/// fpxBank
/////////////////////////////
Expand Down Expand Up @@ -521,7 +496,6 @@ export type StripeElementType =
| 'cardNumber'
| 'cardExpiry'
| 'cardCvc'
| 'cart'
| 'epsBank'
| 'expressCheckout'
| 'fpxBank'
Expand All @@ -548,7 +522,6 @@ export type StripeElement =
| StripeCardNumberElement
| StripeCardExpiryElement
| StripeCardCvcElement
| StripeCartElement
| StripeEpsBankElement
| StripeFpxBankElement
| StripeIbanElement
Expand Down
Loading

0 comments on commit 37ffe0e

Please sign in to comment.