UNPKG

@funkit/connect

Version:

Funkit Connect SDK elevates DeFi apps via web2 sign-ins and one-click checkouts.

91 lines (90 loc) 4.73 kB
import type { BridgeCustomer, BridgeVirtualBankAccount } from '@funkit/api-base'; import { PaymentMethod } from '@funkit/connect-core'; import { type BluvoExchangeType } from '../consts/bluvo'; export { PaymentMethod }; /** Full payment method information used in frontend during payment flows. **/ interface PaymentMethodInfoBase { description: string; paymentMethod: PaymentMethod; title: string; } export interface PaymentMethodCardInfo extends PaymentMethodInfoBase { paymentMethod: PaymentMethod.CARD; } export interface PaymentMethodBrokerageInfo extends PaymentMethodInfoBase { paymentMethod: PaymentMethod.BROKERAGE; deviceId: string; exchange: BluvoExchangeType; } export interface PaymentMethodAccountInfo extends PaymentMethodInfoBase { paymentMethod: PaymentMethod.ACCOUNT_BALANCE; } export interface PaymentMethodTokenTransferInfo extends PaymentMethodInfoBase { paymentMethod: PaymentMethod.TOKEN_TRANSFER; } export interface PaymentMethodBitcoinLightningInfo extends PaymentMethodInfoBase { paymentMethod: PaymentMethod.BITCOIN_LIGHTNING; } export interface PaymentMethodCashAppLightningInfo extends PaymentMethodInfoBase { paymentMethod: PaymentMethod.CASH_APP_LIGHTNING; } export interface PaymentMethodVirtualBankIncompleteInfo extends PaymentMethodInfoBase { paymentMethod: PaymentMethod.VIRTUAL_BANK; matchingFiatAccount: BridgeVirtualBankAccount | undefined; bridgeCustomer: BridgeCustomer | undefined; } export interface PaymentMethodVirtualBankInfo extends PaymentMethodVirtualBankIncompleteInfo { matchingFiatAccount: BridgeVirtualBankAccount; } export type ConnectablePaymentMethodInfo = PaymentMethodAccountInfo | PaymentMethodBrokerageInfo | PaymentMethodVirtualBankInfo; export declare function isConnectablePaymentMethodInfo(value: unknown): value is ConnectablePaymentMethodInfo; /** * Balance-less rails: checkout methods with no on-chain source holding (Card, * Bitcoin Lightning, etc) where "available balance" is not a meaningful concept, * so balance/min/max validation is skipped. Only ACCOUNT_BALANCE and BROKERAGE * carry a measurable holding. Typed to PaymentMethodInfo's methods, not the full * PaymentMethod enum (which also carries Swapped's iframe-only rails). */ export declare function isBalanceLessPaymentMethod(paymentMethod: PaymentMethodInfo['paymentMethod']): boolean; export type PaymentMethodInfo = PaymentMethodCardInfo | PaymentMethodBrokerageInfo | PaymentMethodAccountInfo | PaymentMethodTokenTransferInfo | PaymentMethodBitcoinLightningInfo | PaymentMethodCashAppLightningInfo | PaymentMethodVirtualBankIncompleteInfo; interface CardPaymentMethodParams { paymentMethod: PaymentMethod.CARD; /** We also store client's customization in our database :( */ titleCustomization: string; } interface AccountPaymentMethodParams { paymentMethod: PaymentMethod.ACCOUNT_BALANCE; walletAddress: string; } interface BrokeragePaymentMethodParams { paymentMethod: PaymentMethod.BROKERAGE; deviceId: string; exchange: BluvoExchangeType; } interface TokenTransferPaymentMethodParams { paymentMethod: PaymentMethod.TOKEN_TRANSFER; } interface BitcoinLightningPaymentMethodParams { paymentMethod: PaymentMethod.BITCOIN_LIGHTNING; } interface CashAppLightningPaymentMethodParams { paymentMethod: PaymentMethod.CASH_APP_LIGHTNING; } interface VirtualBankPaymentMethodIncompleteParams { paymentMethod: PaymentMethod.VIRTUAL_BANK; matchingFiatAccount: undefined; bridgeCustomer: BridgeCustomer | undefined; } interface VirtualBankPaymentMethodParams { paymentMethod: PaymentMethod.VIRTUAL_BANK; matchingFiatAccount: BridgeVirtualBankAccount; bridgeCustomer: BridgeCustomer | undefined; } export declare function createPaymentMethodInfo(params: CardPaymentMethodParams): PaymentMethodCardInfo; export declare function createPaymentMethodInfo(params: AccountPaymentMethodParams): PaymentMethodAccountInfo; export declare function createPaymentMethodInfo(params: TokenTransferPaymentMethodParams): PaymentMethodTokenTransferInfo; export declare function createPaymentMethodInfo(params: BitcoinLightningPaymentMethodParams): PaymentMethodBitcoinLightningInfo; export declare function createPaymentMethodInfo(params: CashAppLightningPaymentMethodParams): PaymentMethodCashAppLightningInfo; export declare function createPaymentMethodInfo(params: VirtualBankPaymentMethodIncompleteParams): PaymentMethodVirtualBankIncompleteInfo; export declare function createPaymentMethodInfo(params: VirtualBankPaymentMethodParams): PaymentMethodVirtualBankInfo; export declare function createPaymentMethodInfo(params: BrokeragePaymentMethodParams): PaymentMethodBrokerageInfo;