How cybersource/cybersource-plugins-commercetools works
This is a Commercetools HTTP API Extension that mediates payment operations between Commercetools and Cybersource. The main flow is an API-extension request, payment-method handling and request preparation, a Cybersource operation, then a synchronous response to Commercetools; order creation remains front-end business logic. The README also documents tokenization, capture, refund, authorization reversal, payment synchronization, and network-token webhooks. The sampled source confirms authorization request construction and payer-authentication setup; other subsystem links reflect documented capabilities and module names, not inspected call sites.
Main entry points: apiController.ts Payment controller · PaymentHandler.ts Payment actions · PrepareFields.ts Request preparation · PaymentAuthorizationService.ts Authorization
Components 20
Extension runtime
- Extension entry
src/index.ts - Request routing
src/app/RouterHandler.ts - Application handler
src/app/AppHandler.ts - Extension response
src/apiController.ts
Payment processing
- Payment controller
src/apiController.ts - Payment actions
src/utils/PaymentHandler.ts - Payment methods
src/models/PaymentMethodFactory.ts - Method strategies
src/models/PaymentMethodStrategy.ts - Request preparation
src/requestBuilder/PrepareFields.ts - Authorization
src/service/payment/PaymentAuthorizationService.ts - Payer authentication
src/service/payment/PayerAuthenticationSetupService.ts
Platform integrations
- Commercetools API
src/utils/api/CommercetoolsApi.ts - Cybersource API
src/utils/api/IsvApi.ts
Payment lifecycle
- Token management
src/service/payment/AddTokenService.ts - Webhook subscriptions
src/service/payment/CreateWebhookSubscription.ts - Payment synchronization
src/service/payment/DecisionSyncService.ts - Capture and refund
src/service/payment/PaymentCaptureService.ts - Authorization reversal
src/service/payment/PaymentAuthorizationReversal.ts
Other components
- Storefront
- Commercetools
Connections 21
- Storefront → Commercetools: submits payment
- Commercetools → Extension entry: invokes extension
- Extension entry → Request routing: dispatches request
- Request routing → Application handler: routes request
- Application handler → Payment controller: handles payment
- Payment controller → Payment actions: dispatches actions
- Payment actions → Payment methods: selects method
- Payment methods → Method strategies: resolves strategy
- Payment actions → Request preparation: prepares request
- Authorization → Request preparation: builds fields
- Authorization → Cybersource API: submits authorization
- Payer authentication → Request preparation: builds setup request
- Payer authentication → Cybersource API: starts authentication
- Payment controller → Commercetools API: uses platform API
- Payment controller → Token management: manages tokens
- Payment controller → Webhook subscriptions: manages subscriptions
- Payment controller → Payment synchronization: synchronizes payments
- Payment controller → Capture and refund: captures or refunds
- Payment controller → Authorization reversal: reverses authorization
- Payment controller → Extension response: returns result
- Extension response → Commercetools: responds synchronously