Skip to content

Add PaymentDestination interface for lightweight server destinations#128

Merged
badjer merged 1 commit intomainfrom
feature/payment-destination-interface
Dec 17, 2025
Merged

Add PaymentDestination interface for lightweight server destinations#128
badjer merged 1 commit intomainfrom
feature/payment-destination-interface

Conversation

@badjer
Copy link
Contributor

@badjer badjer commented Dec 17, 2025

Summary

  • Adds PaymentDestination interface to @atxp/common - minimal interface for server destinations
  • Updates Account type to extend PaymentDestination (backwards compatible)
  • Adds AccountIdDestination class - lightweight destination using just an accountId
  • Updates server ATXPConfig.destination type from Account to PaymentDestination

Motivation

Sprites and other services that receive payments don't need a full connection_token to operate. They only need:

  • getAccountId() - to identify where payments go
  • getSources() - to provide payment options (public endpoint, no auth)

This change allows servers to use:

import { AccountIdDestination } from '@atxp/common';
const destination = new AccountIdDestination('abc123');

Instead of requiring a full connection string:

import { ATXPAccount } from '@atxp/common';
const destination = new ATXPAccount(process.env.ATXP_CONNECTION_STRING!);

Changes

New interface (types.ts):

export interface PaymentDestination {
  getAccountId: () => Promise<AccountId>;
  getSources: () => Promise<Source[]>;
}

Updated Account (types.ts):

export type Account = PaymentDestination & {
  paymentMakers: PaymentMaker[];
}

New class (accountIdDestination.ts):

  • Takes accountId string (qualified atxp:abc123 or unqualified abc123)
  • Calls public /account/{id}/sources endpoint (no auth needed)
  • No connection_token required

Test plan

  • All existing tests pass
  • Manual test with sprite using AccountIdDestination

🤖 Generated with Claude Code

Introduces a minimal PaymentDestination interface that only requires
getAccountId() and getSources() - the bare minimum needed for server
middleware destinations. This allows sprites and other services to
operate without a full connection_token.

Changes:
- Add PaymentDestination interface to @atxp/common
- Update Account type to extend PaymentDestination
- Add AccountIdDestination class that implements PaymentDestination
  using just an accountId string (no connection_token required)
- Update server ATXPConfig.destination type from Account to PaymentDestination

This enables servers to use:
  new AccountIdDestination('abc123')
instead of requiring:
  new ATXPAccount(connectionString)

Existing code using ATXPAccount continues to work unchanged since
Account extends PaymentDestination.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@badjer badjer merged commit 94901f4 into main Dec 17, 2025
1 check passed
@badjer badjer deleted the feature/payment-destination-interface branch December 17, 2025 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant