Skip to content

Latest commit

 

History

History
115 lines (87 loc) · 2.36 KB

File metadata and controls

115 lines (87 loc) · 2.36 KB

API Reference

Link2PayClient

new Link2PayClient(options: Link2PayClientOptions)

Link2PayClientOptions

interface Link2PayClientOptions {
  apiKey: string;
  baseUrl?: string;
  environment?: "sandbox" | "production";
  timeoutMs?: number;
  fetch?: typeof fetch;
  userAgentSuffix?: string;
}

Properties

  • paymentLinks: PaymentLinksResource
  • baseUrl: string

PaymentLinksResource

create(request)

create(request: CreatePaymentLinkRequest): Promise<PaymentLink>

get(paymentLinkId)

get(paymentLinkId: string): Promise<PaymentLink>

Alias of retrieve(paymentLinkId).

retrieve(paymentLinkId)

retrieve(paymentLinkId: string): Promise<PaymentLink>

list(query?)

list(query?: ListPaymentLinksQuery): Promise<ListPaymentLinksResponse>

Runtime validation behavior

For JavaScript and TypeScript consumers, the SDK validates key inputs before network calls:

  • apiKey must be a non-empty string
  • baseUrl must be a valid absolute URL
  • timeoutMs must be a positive integer
  • CreatePaymentLinkRequest.amount must be a positive decimal string with up to 2 fraction digits
  • CreatePaymentLinkRequest.currency must be a 3-letter uppercase ISO code (for example, USD)
  • list({ limit }) must use an integer from 1 to 100

Request and Response Types

interface CreatePaymentLinkRequest {
  amount: string;
  currency: string;
  reference: string;
  customerEmail?: string;
  redirectUrl?: string;
  webhookUrl?: string;
  expiresAt?: string;
  metadata?: Record<string, string>;
}

interface PaymentLink {
  id: string;
  url: string;
  status: "draft" | "active" | "paid" | "expired" | "cancelled";
  settlementStatus: "pending" | "settled" | "failed";
  amount: string;
  currency: string;
  reference: string;
  customerEmail?: string;
  redirectUrl?: string;
  webhookUrl?: string;
  expiresAt?: string;
  paidAt?: string;
  createdAt: string;
  updatedAt: string;
  metadata?: Record<string, string>;
}

Webhooks

Import from the dedicated entrypoint:

import {
  verifyWebhookSignature,
  assertWebhookSignature
} from "@link2pay/sdk/webhooks";

verifyWebhookSignature(input)

Returns true when signature and timestamp checks pass, otherwise false.

assertWebhookSignature(input)

Throws WebhookSignatureError when verification fails.