@vansite/ts-sharetribe-flex-sdk
Version:
This is a TypeScript SDK for Sharetribe Flex API. It reduces the complexity of the API and provides a more user-friendly interface.
63 lines (62 loc) • 2.72 kB
TypeScript
/**
* @fileoverview Client for managing the current user's Stripe Customer object in the Sharetribe Marketplace API.
*
* Use this to:
* - Create a Stripe Customer (required for charging users)
* - Attach payment methods (e.g. saved cards)
* - Remove payment methods
*
* All operations are performed on the current authenticated user.
*
* @see https://www.sharetribe.com/api-reference/marketplace.html#stripe-customer
*/
import type { AxiosResponse } from "axios";
import MarketplaceApi from "./index";
import { ExtraParameter, StripeCustomerAddPaymentMethodParameter, StripeCustomerCreateParameter, StripeCustomerDeletePaymentMethodParameter, StripeCustomerResponse } from "../../types";
/**
* Stripe Customer API client (current user)
*/
declare class StripeCustomer {
readonly authRequired = true;
private readonly axios;
private readonly endpoint;
private readonly headers;
constructor(api: MarketplaceApi);
/**
* Create a Stripe Customer for the current user
*
* @template P
* @template EP
* @param {P & StripeCustomerCreateParameter} params
* @param {EP} [extraParams]
* @returns {Promise<AxiosResponse<StripeCustomerResponse<"create", P, EP>>>}
*
* @example
* await sdk.stripeCustomer.create({
* stripePaymentMethodId: "pm_card_visa",
* stripeCustomerEmail: "user@example.com"
* });
*/
create<P extends StripeCustomerCreateParameter, EP extends ExtraParameter | undefined = undefined>(params: P, extraParams?: EP): Promise<AxiosResponse<StripeCustomerResponse<"create", P, EP>>>;
/**
* Attach a new payment method to the current user's Stripe Customer
*
* @template P
* @template EP
* @param {P & StripeCustomerAddPaymentMethodParameter} params
* @param {EP} [extraParams]
* @returns {Promise<AxiosResponse<StripeCustomerResponse<"addPaymentMethod", P, EP>>>}
*/
addPaymentMethod<P extends StripeCustomerAddPaymentMethodParameter, EP extends ExtraParameter | undefined = undefined>(params: P, extraParams?: EP): Promise<AxiosResponse<StripeCustomerResponse<"addPaymentMethod", P, EP>>>;
/**
* Remove a saved payment method
*
* @template P
* @template EP
* @param {P & StripeCustomerDeletePaymentMethodParameter} params
* @param {EP} [extraParams]
* @returns {Promise<AxiosResponse<StripeCustomerResponse<"deletePaymentMethod", P, EP>>>}
*/
deletePaymentMethod<P extends StripeCustomerDeletePaymentMethodParameter, EP extends ExtraParameter | undefined = undefined>(params: P, extraParams?: EP): Promise<AxiosResponse<StripeCustomerResponse<"deletePaymentMethod", P, EP>>>;
}
export default StripeCustomer;