File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
src/routes/(console)/organization-[organization]/billing Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 5555 async function handleSubmit() {
5656 isButtonDisabled = true ;
5757 try {
58- if (paymentMethodId === null ) {
58+ if (paymentMethodId === null || paymentMethodId === ' $new ' ) {
5959 try {
6060 if (showState && ! state ) {
6161 throw Error (' Please select a state' );
6565 method = await setPaymentMethod (paymentMethod .id , name , state );
6666 } else {
6767 const card = await submitStripeCard (name , $organization .$id );
68- if (card && Object .hasOwn (card , ' id' )) {
68+ // When Stripe returns an expanded PaymentMethod for US cards, we need state.
69+ if (Object .hasOwn (card , ' id' ) && (card as PaymentMethod )?.card ) {
6970 if ((card as PaymentMethod ).card ?.country === ' US' ) {
7071 paymentMethod = card as PaymentMethod ;
7172 showState = true ;
7273 return ;
7374 }
74- } else if (card && Object .hasOwn (card , ' $id' )) {
75+ }
76+
77+ // Otherwise, we expect an Appwrite PaymentMethodData with `$id`.
78+ if (Object .hasOwn (card , ' $id' )) {
7579 method = card as PaymentMethodData ;
7680 }
7781 }
You can’t perform that action at this time.
0 commit comments