Skip to content

Commit e8913ae

Browse files
Merge pull request #2234 from appwrite/fix-error-adding-pm
Fix: adding payment method error when PM is empty
2 parents 0059958 + 1fc6cbb commit e8913ae

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/lib/components/billing/paymentModal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
4343
const card = await submitStripeCard(name, page?.params?.organization ?? null);
4444
if (card && Object.hasOwn(card, 'id')) {
45-
if ((card as PaymentMethod).card.country === 'US') {
45+
if ((card as PaymentMethod).card?.country === 'US') {
4646
paymentMethod = card as PaymentMethod;
4747
showState = true;
4848
return;

src/lib/stores/stripe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export async function submitStripeCard(name: string, organizationId?: string) {
102102
}
103103

104104
if (setupIntent && setupIntent.status === 'succeeded') {
105-
if ((setupIntent.payment_method as PaymentMethod).card.country === 'US') {
105+
if ((setupIntent.payment_method as PaymentMethod).card?.country === 'US') {
106106
// need to get state
107107
return setupIntent.payment_method as PaymentMethod;
108108
}

src/routes/(console)/organization-[organization]/billing/replaceCard.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
} else {
5555
const card = await submitStripeCard(name, organization.$id);
5656
if (card && Object.hasOwn(card, 'id')) {
57-
if ((card as PaymentMethod).card.country === 'US') {
57+
if ((card as PaymentMethod).card?.country === 'US') {
5858
paymentMethod = card as PaymentMethod;
5959
showState = true;
6060
return;

src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
} else {
6767
const card = await submitStripeCard(name, $organization.$id);
6868
if (card && Object.hasOwn(card, 'id')) {
69-
if ((card as PaymentMethod).card.country === 'US') {
69+
if ((card as PaymentMethod).card?.country === 'US') {
7070
paymentMethod = card as PaymentMethod;
7171
showState = true;
7272
return;

src/routes/(console)/organization-[organization]/billing/wizard/paymentDetails.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
} else {
3535
const card = await submitStripeCard(name, $organization.$id);
3636
if (card && Object.hasOwn(card, 'id')) {
37-
if ((card as PaymentMethod).card.country === 'US') {
37+
if ((card as PaymentMethod).card?.country === 'US') {
3838
paymentMethod = card as PaymentMethod;
3939
showState = true;
4040
return;

0 commit comments

Comments
 (0)