Examples / Class diagrams
Payment provider classes
A class design that hides several payment providers behind one interface, with a factory picking the provider and a shared result type.
- Class diagram
- TypeScript
Open in Plotix
A copy you can edit, or ask the agent to change.
Plotix's agent drew it from this request
Draw a class diagram of a payments module in TypeScript that hides providers behind one interface: a PaymentProvider interface with charge, refund and webhook methods, StripeProvider and PayPalProvider implementing it, a ProviderFactory, a PaymentService using the interface, and Money and PaymentResult value types.
What's in it
- PaymentProvider
- StripeProvider
- PayPalProvider
- ProviderFactory
- PaymentService
- Money
- PaymentResult
How the parts connect
- StripeProvider → PaymentProvider
- PayPalProvider → PaymentProvider
- ProviderFactory → StripeProvider
- ProviderFactory → PayPalProvider
- PaymentService → ProviderFactory
- PaymentService → PaymentProvider
- PaymentProvider → Money
- PaymentProvider → PaymentResult
More on class diagrams.
Related examples
OAuth login with PKCESequence · How a single-page app signs a user in with OAuth 2.0 authorization code and PKCE, from th…
Stripe checkout and webhookFlow · The steps from a cart to a paid order with Stripe Checkout, including the webhook that co…
Serverless API on AWSDeployment · Where a serverless web API runs on AWS: CloudFront and S3 for the site, API Gateway and L…