Relocate the ~6k-file docs tree from the repo root into plugins/document-navigator/docs/ so the plugin is self-contained and portable. docs/superpowers/ (specs and plans) stays at the repo root. Moved via cp+rm rather than git mv because directory rename() fails with EPERM on this WSL /mnt DrvFs mount; git rename-detection pairs the identical-content files at commit time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5.0 KiB
5.0 KiB
@suaveplan/payment-provider-square - Universal Square Payments API adapter for @suaveplan/payment. Ships SquareProvider (implements PaymentProvider with literal name "square"), SquareConfig (extends ApiKeyConfig with locationId, sandbox, apiVersion, randomId), and the Square-specific payment/refund mappers. Built on the @suaveplan/payment-providers foundation (httpRequest, composeAbortSignal, PAYMENT_PROVIDER_CODES, PaymentProviderError).
Universal Square Payments API adapter for @suaveplan/payment.
Ships the SquareProvider class (implements the structural
PaymentProvider contract with literal name: "square"), the
SquareConfig interface (extends ApiKeyConfig from
@suaveplan/payment-providers with the Square-specific locationId,
sandbox, apiVersion, and randomId fields), and the
Square-specific payment / refund mappers (mapPayment, mapRefund,
mapPaymentStatus, mapRefundStatus).
Built on the @suaveplan/payment-providers foundation — every
outbound HTTP call goes through httpRequest, which handles JSON
serialisation, the per-call timeout signal, external AbortSignal
composition, and typed PaymentProviderError raising.
Documentation tree
- payment — Translates between Square's
Paymentenvelope (as returned byPOST /v2/payments,POST /v2/payments/{id}/complete,… - refund — Translates Square's
Refundenvelope (as returned byPOST /v2/refunds) into@suaveplan/payment'sRefundshape. T… - square —
SquareProvideris the Square Payments API adapter for@suaveplan/payment. It implements the structural `PaymentProv…- square —
SquareProvideris the Square Payments API adapter for@suaveplan/payment. It implements the structural `PaymentProv…
- square —
- types — Defines the configuration shape
SquareProvideraccepts and the three default constants the provider falls back to whe…- config — Defines the configuration shape
SquareProvideraccepts and the three default constants the provider falls back to whe…
- config — Defines the configuration shape
Install
bun add @suaveplan/payment-provider-square @suaveplan/payment-providers @suaveplan/payment
Quick start
import { ProviderRegistry } from "@suaveplan/payment-providers";
import { SquareProvider } from "@suaveplan/payment-provider-square";
import { PaymentEngine } from "@suaveplan/payment";
const registry = new ProviderRegistry();
registry.register(
new SquareProvider({
apiKey: process.env.SQUARE_ACCESS_TOKEN ?? "",
locationId: process.env.SQUARE_LOCATION_ID ?? "",
})
);
const engine = new PaymentEngine({ provider: registry.get("square") });
const intent = await engine.createIntent({
amount: { amount: 5000n, currency: "USD" },
});
Features
SquareProvider— full Square Payments API lifecycle (createIntent,confirmIntent,captureIntent,cancelIntent,refund,getIntent) with literalname: "square".SquareConfig— extendsApiKeyConfig; adds requiredlocationIdplus optionalsandbox,apiVersion,randomId.- Sandbox toggle —
sandbox: trueflips the default base URL tohttps://connect.squareupsandbox.com/v2. ExplicitbaseUrlalways wins. - Pinned
Square-Version— defaults to2024-01-18; override viaapiVersionto opt into a newer API surface. - Injectable
randomId— fills missingidempotency_keyfields onCreatePayment+RefundPaymentcalls. Tests pass a deterministic counter; production defaults tocrypto.randomUUID(). - Universal — no
node:,bun:,fs,path,cryptoimports; runs on Node, Bun, browsers, and Web Workers. PaymentProviderError-only — every failure surfaces as a typedPaymentProviderErrorvia the foundation'shttpRequest.- 100% test coverage (Istanbul) + sibling
.mdper implementation file + 5 subpath exports.
Modules
src/square/square.md—SquareProviderclass and lifecycle methods.src/types/config.md—SquareConfig,SQUARE_DEFAULT_BASE_URL,SQUARE_SANDBOX_BASE_URL,SQUARE_DEFAULT_API_VERSION.src/mapping/payment.md—mapPayment,mapPaymentStatus,SquarePaymentDto,SquareMoney,SquareCard.src/mapping/refund.md—mapRefund,mapRefundStatus,SquareRefundDto.
Related
@suaveplan/payment-providers—ProviderRegistry,definePaymentProvider,httpRequest,composeAbortSignal,PAYMENT_PROVIDER_CODES,PaymentProviderError,ApiKeyConfig/OAuthConfig/MerchantKeyConfig,FetchLike/RandomIdFn/NowFn/Base64EncodeFn.@suaveplan/payment—PaymentEngine,WebhookVerifier,PaymentProviderinterface, the canonicalPaymentIntent/Refund/PaymentStatus/RefundStatusshapes.
License
MIT