update payment method details upon completion

This commit is contained in:
Damodar Lohani committed 2023-02-10 11:26:06 +05:45
1 parent bef77eaabd
commit 5c9579e13f
2 files changed
+14 -3

No files matched your search

+9 -2
View File
@@ -27,10 +27,17 @@ export class Billing {
);
}
async updatePaymentMethod(teamId: string, paymentMethodId: string) {
async updatePaymentMethod(teamId: string, paymentMethodId: string, providerMethodId: string) {
const path = `/teams/${teamId}/payment-methods/${paymentMethodId}`;
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call('PUT', uri, { 'content-type': 'application/json' }, {});
return await this.client.call(
'PUT',
uri,
{ 'content-type': 'application/json' },
{
providerMethodId
}
);
}
async updateProjectPlan(projectId: string, billingPlan: string) {
@@ -82,7 +82,11 @@
});
} else if (setupIntent && setupIntent.status === 'succeeded') {
//update payment method
cloudSdk.billing.updatePaymentMethod($organization.$id, paymentMethod.$id);
await cloudSdk.billing.updatePaymentMethod(
$organization.$id,
paymentMethod.$id,
setupIntent.payment_method
);
}
}
}