Add payment mandate setup and check for missing mandate

This commit is contained in:
Arman
2024-02-12 15:51:26 +01:00
parent 6c69f5bc98
commit 79730d8b47
2 changed files with 29 additions and 0 deletions
+21
View File
@@ -18,6 +18,7 @@ export type PaymentMethodData = {
clientSecret: string;
failed: boolean;
name: string;
mandateId?: string;
};
export type PaymentList = {
@@ -849,6 +850,26 @@ export class Billing {
);
}
async setupPaymentMandate(
organizationId: string,
paymentMethodId: string
): Promise<PaymentMethodData> {
const path = `/account/payment-methods/${paymentMethodId}/setup`;
const params = {
organizationId,
paymentMethodId
};
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call(
'post',
uri,
{
'content-type': 'application/json'
},
params
);
}
async listAddresses(queries: Query[] = []): Promise<AddressesList> {
const path = `/account/billing-addresses`;
const params = {
+8
View File
@@ -40,6 +40,7 @@
import UsageRates from './wizard/cloudOrganization/usageRates.svelte';
import { activeHeaderAlert, consoleVariables } from './store';
import { headerAlert } from '$lib/stores/headerAlert';
import { sdk } from '$lib/stores/sdk';
function kebabToSentenceCase(str: string) {
return str
@@ -248,6 +249,13 @@
}
});
async function checkForMandate() {
const paymentMethods = await sdk.forConsole.billing.listPaymentMethods();
const missingMandate = paymentMethods.paymentMethods.filter(
(method) => method.mandateId === null && method.country === 'in'
);
}
function checkForFeedback(interval: number) {
const minutes = interval / 60000;
feedback.increaseElapsed(minutes);