Payment processor hierarchy

Illustrative module: one processor contract, a retrying base class, and five provider implementations.

Payment processor hierarchy Illustrative module: one processor contract, a retrying base class, and five provider implementations. CheckoutOrchestrator · Runs one checkout from order to receipt · Class CheckoutOrchestrator -registryProcessorRegistry -clockClock +checkout( order: Order, key: IdempotencyKey ): CheckoutResult +cancelPendingAuthorization( orderId: OrderId ): void ProcessorRegistry · Selects a processor for a payment method · Class ProcessorRegistry -processors: Map<MethodType, PaymentProcessor> +processorFor( method: PaymentMethod ): PaymentProcessor PaymentProcessor · Authorize, capture, and refund contract · Interface «interface» PaymentProcessor +authorize( request: AuthorizationRequest ): AuthorizationResult +capture( authorization: AuthorizationId, amount: Money ): CaptureResult +refund( capture: CaptureId, amount: Money ): RefundResult Order · Aggregate root for one purchase · Class Order +idOrderId +totalMoney +statusPaymentStatus +addLine( sku: Sku, quantity: int ): LineItem +markAuthorized( authorization: AuthorizationId ): void PaymentStatus · Lifecycle of the order's payment · Enumeration «enumeration» PaymentStatus PENDING AUTHORIZED CAPTURED REFUNDED FAILED RetryingProcessorBase · Shared retry, timeout, and idempotency handling · Abstract class «abstract» RetryingProcessorBase +DEFAULT_TIMEOUTDuration #retryPolicyRetryPolicy +authorize( request: AuthorizationRequest ): AuthorizationResult #sendToProvider( request: ProviderRequest ): ProviderResponse BankTransferProcessor · Asynchronous transfer without provider retries · Class BankTransferProcessor +authorize( request: AuthorizationRequest ): AuthorizationResult -awaitSettlement( transfer: TransferId ): SettlementResult LineItem · Immutable priced order line · Record «record» LineItem +skuSku +quantityint +unitPriceMoney StripeCardProcessor · Card payments through Stripe · Class StripeCardProcessor #sendToProvider( request: ProviderRequest ): ProviderResponse AdyenCardProcessor · Card payments through Adyen · Class AdyenCardProcessor #sendToProvider( request: ProviderRequest ): ProviderResponse PayPalWalletProcessor · Wallet payments through PayPal · Class PayPalWalletProcessor #sendToProvider( request: ProviderRequest ): ProviderResponse -exchangeBillingAgreementToken( token: String ): AgreementId selects via holds updates owns lines Legend Depends on Association Inherits Implements Composition Aggregation