Skip to content

Instantly share code, notes, and snippets.

@0x666c6f
Created September 19, 2024 20:44
Show Gist options
  • Select an option

  • Save 0x666c6f/e78ef187236161550105867775ec3e47 to your computer and use it in GitHub Desktop.

Select an option

Save 0x666c6f/e78ef187236161550105867775ec3e47 to your computer and use it in GitHub Desktop.

Technical Case Study: Stripe Payment Distribution System

Background

You are tasked with building a backend system for a marketplace platform that allows creators to sell digital products. The platform needs to handle payments from customers and distribute the earnings among multiple connected accounts (e.g., the creator, the platform, and potentially other stakeholders).

Requirements

  1. Create a GraphQL API using TypeScript that integrates with Stripe.
  2. Implement the following functionalities: a. Create Stripe Connect accounts for creators. b. Accept payments from customers. c. Distribute payment amounts between multiple connected accounts.
  3. Containerize the application using Docker.
  4. Implement proper error handling and logging.
  5. Write unit tests for critical components.

Detailed Tasks

1. Set up the Project

  • Initialize a new TypeScript project.
  • Set up a GraphQL server using any framework or library of your choice.
  • Configure Docker for the project.

2. Stripe Integration

  • Implement Stripe Connect account creation for creators.
  • Create a payment intent for customer purchases.
  • Handle successful payments and failed payments.

3. Payment Distribution

  • Implement a flexible payment distribution system that can split payments between multiple connected accounts based on predefined rules.
  • Ensure the system can handle various scenarios (e.g., platform fee, creator earnings, affiliate commissions).

4. GraphQL API

  • Design and implement a GraphQL API that supports the required operations:
    • Creating Connect accounts
    • Creating payment intents
    • Confirming payments
  • You have flexibility in naming and structuring your GraphQL operations.

5. Error Handling and Logging

  • Implement proper error handling for Stripe API calls and other potential failure points.
  • Set up a logging system to track important events and errors.

6. Testing

  • Write unit tests for critical components, especially those handling payment distribution logic.

7. Dockerization

  • Create Dockerfile(s) to containerize the application.
  • Create a Docker compose file if needed

Evaluation Criteria

  1. Code quality and organization
  2. Proper use of TypeScript features
  3. GraphQL API design and implementation
  4. Stripe API integration and error handling
  5. Payment distribution logic correctness
  6. Docker configuration
  7. Test coverage and quality
  8. Documentation and code comments

Submission Guidelines

  1. Provide a GitHub repository with your solution.
  2. Include a README.md file with:
    • Setup instructions
    • An overview of your solution's architecture
    • Any assumptions or design decisions you made
    • Suggestions for further improvements or scaling considerations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment