@coinbasejs/commerce
Version:
Coinbase Developer Platform Commerce package
224 lines (219 loc) • 7.03 kB
TypeScript
type GetChargeResponse = {
data: Charge;
warnings: string[];
};
declare function getCharge(id: string, config: RequestConfig): Promise<GetChargeResponse>;
type GetChargesResponse = {
data: Charge[];
warnings: string[];
};
declare function getCharges(config: RequestConfig): Promise<GetChargesResponse>;
type ChargePricing = {
amount: string;
currency: string;
};
type CreateChargeParameters = {
name: string;
description: string;
pricing_type: ChargePricingType;
local_price: ChargePricing;
};
type CreateChargeResponse = {
data: Charge;
warnings: string[];
};
declare function createCharge(parameters: CreateChargeParameters, config: RequestConfig): Promise<CreateChargeResponse>;
type ChargePricingType = "fixed_price" | "no_price";
type TimelineStatus = "COMPLETED" | "EXPIRED" | "FAILED" | "NEW" | "PENDING" | "SIGNED";
type Charge = {
brand_color: string;
brand_logo_url: string;
charge_kind: "WEB3";
code: string;
collected_email: boolean;
created_at: string;
description: string;
expires_at: string;
hosted_url: string;
id: string;
name: string;
organization_name: string;
payments: string[];
pricing: {
local: ChargePricing;
settlement: ChargePricing;
};
pricing_type: ChargePricingType;
pwcb_only: boolean;
redirects: {
cancel_url: string;
success_url: string;
will_redirect_after_success: boolean;
};
support_email: string;
third_party_provider: string;
timeline: Array<{
status: TimelineStatus;
time: string;
}>;
web3_data: {
contract_caller_request_id: string;
failure_events: Array<{
input_token_address: string;
network_fee_paid: string;
reason: string;
sender: string;
timestamp: string;
tx_hash: string;
}>;
settlement_currency_addresses: Record<string, string>;
subsidized_payments_chain_to_tokens: Record<string, {
tokenAddresses: string[];
}>;
success_events: Array<{
finalized: boolean;
input_token_address: string;
input_token_amount: string;
network_fee_paid: string;
recipient: string;
sender: string;
timestamp: string;
tx_hash: string;
}>;
transfer_intent: {
call_data: {
deadline: string;
fee_amount: string;
id: string;
operator: string;
prefix: string;
recipient: string;
recipient_amount: string;
recipient_currency: string;
refund_destination: string;
signature: string;
};
metadata: {
chain_id: number;
contract_address: string;
sender: string;
};
contract_address: string;
contract_addresses: Record<string, string>;
} | null;
};
web3_retail_payment_metadata: {
quote_id: string;
source_amount: {
amount: string | null;
currency: string | null;
};
exchange_rate_with_spread: {
amount: string | null;
currency: string | null;
};
exchange_rate_without_spread: {
amount: string | null;
currency: string | null;
};
max_retail_payment_value_usd: number;
fees: string[];
};
web3_retail_payments_enabled: boolean;
};
type GetCheckoutResponse = {
data: Checkout;
warning: string[];
};
declare function getCheckout(id: string, config: RequestConfig): Promise<GetCheckoutResponse>;
type GetCheckoutsResponse = {
data: Checkout[];
warning: string[];
};
declare function getCheckouts(config: RequestConfig): Promise<GetCheckoutsResponse>;
type CheckoutRequestInfo = "name" | "email" | "address" | "phone" | "employer" | "occupation";
type CreateCheckoutParameters = {
name: string;
description: string;
local_price: {
amount: string;
currency: string;
};
logo_url: string;
pricing_type: CheckoutPricingType;
requested_info: CheckoutRequestInfo[];
};
type CreateCheckoutResponse = {
data: Checkout;
warnings: string[];
};
declare function createCheckout(parameters: CreateCheckoutParameters, config: RequestConfig): Promise<CreateCheckoutResponse>;
type CheckoutPricingType = "fixed_price" | "no_price";
type Checkout = {
brand_color: string;
brand_logo_url: string;
coinbase_managed_merchant: boolean;
created_at: string;
description: string;
id: string;
local_price: {
amount: string | null;
currency: string | null;
};
logo_url: string;
name: string;
organization_name: string;
pricing_type: CheckoutPricingType;
requested_info: CheckoutRequestInfo[];
resource: string;
updated_at: string;
};
type GetEventResponse = {
data: Event;
warnings: string[];
};
declare function getEvent(id: string, config: RequestConfig): Promise<GetEventResponse>;
type GetEventsResponse = {
pagination: {
order: "asc" | "desc";
starting_after: string | null;
ending_before: string | null;
total: number;
limit: number;
yielded: number;
cursor_range: string[];
previous_uri: string[];
next_uri: string;
};
data: Array<Event>;
};
declare function getEvents(config: RequestConfig): Promise<GetEventsResponse>;
type Event = {
api_version: string;
created_at: string;
data: Charge | Checkout;
id: string;
resource: "event";
type: string;
};
type Client = {
__url: string;
createCharge: (parameters: CreateChargeParameters) => Promise<Charge>;
createCheckout: (parameters: CreateCheckoutParameters) => Promise<Checkout>;
getCharge: (id: string) => Promise<Charge>;
getCharges: () => Promise<Charge[]>;
getCheckout: (id: string) => Promise<Checkout>;
getCheckouts: () => Promise<Checkout[]>;
getEvent: (id: string) => Promise<Event>;
getEvents: () => Promise<Event[]>;
};
type ClientConfig = {
apiKey: string;
baseUrl?: string;
};
declare function createClient(config: ClientConfig): Client;
type RequestConfig = {
apiKey: string;
baseUrl?: string;
};
export { type Charge, type ChargePricing, type ChargePricingType, type CheckoutPricingType, type CheckoutRequestInfo, type Client, type ClientConfig, type CreateChargeParameters, type CreateChargeResponse, type CreateCheckoutParameters, type CreateCheckoutResponse, type Event, type GetChargeResponse, type GetChargesResponse, type GetCheckoutResponse, type GetCheckoutsResponse, type GetEventResponse, type GetEventsResponse, type TimelineStatus, createCharge, createCheckout, createClient, getCharge, getCharges, getCheckout, getCheckouts, getEvent, getEvents };