@cocalc/server
Version:
CoCalc server functionality: functions used by either the hub and the next.js server
52 lines (51 loc) • 2.24 kB
TypeScript
import type { PostgreSQL } from "@cocalc/database/postgres/types";
import Stripe from "stripe";
export { Stripe };
interface HubClient {
account_id: string;
database: PostgreSQL;
dbg: (f: string) => Function;
push_to_client: Function;
error_to_client: Function;
assert_user_is_in_group: Function;
}
declare type StripeCustomer = any;
declare type Message = any;
export declare class StripeClient {
private client;
private stripe_customer_id?;
constructor(client: Partial<HubClient>);
private dbg;
get_customer_id(): Promise<string | undefined>;
need_customer_id(): Promise<string>;
private stripe_api_pager_options;
get_customer(customer_id?: string): Promise<StripeCustomer>;
handle_mesg(mesg: Message): Promise<void>;
mesg_get_customer(_mesg: Message): Promise<Message>;
mesg_create_source(mesg: Message): Promise<void>;
private create_new_stripe_customer_from_card_token;
private add_card_to_existing_stripe_customer;
mesg_delete_source(mesg: Message): Promise<void>;
mesg_set_default_source(mesg: Message): Promise<void>;
update_database(): Promise<any>;
mesg_update_source(mesg: Message): Promise<void>;
sales_tax(customer_id: string): Promise<number>;
mesg_create_subscription(mesg: Message): Promise<void>;
mesg_cancel_subscription(mesg: Message): Promise<void>;
mesg_update_subscription(mesg: Message): Promise<void>;
mesg_get_subscriptions(mesg: Message): Promise<Message>;
mesg_get_coupon(mesg: Message): Promise<Message>;
private validate_coupon;
mesg_get_charges(mesg: Message): Promise<Message>;
mesg_get_invoices(mesg: Message): Promise<Message>;
mesg_admin_create_invoice_item(mesg: Message): Promise<void>;
mesg_get_available_upgrades(_mesg: Message): Promise<Message>;
mesg_remove_all_upgrades(mesg: Message): Promise<void>;
mesg_sync_site_license_subscriptions(): Promise<void>;
cancelEverything(): Promise<void>;
getPaymentMethods(): Promise<Message>;
setDefaultSource(default_source: string): Promise<void>;
deletePaymentMethod(id: string): Promise<void>;
createPaymentMethod(token: string): Promise<void>;
cancelSubscription(id: string): Promise<void>;
}