-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
UD-ComplexMuch more difficult to implement, requires experience.Much more difficult to implement, requires experience.in progressan issue is being implemented.an issue is being implemented.new featureimplement a new featureimplement a new feature
Description
Feature: Integrate Payment Gateway (e.g., Stripe)
Is your feature request related to a problem? Please describe.
To allow users to subscribe to paid plans, UnravelDocs needs to integrate with a payment gateway to securely process payments and manage subscriptions.
Describe the solution you'd like
Integrate a third-party payment gateway (Stripe is a common choice and will be assumed for this issue, but principles apply to others like PayPal, Braintree).
- Gateway Setup: Create an account with the chosen payment gateway and configure products/prices corresponding to the defined subscription plans.
- SDK/API Integration: Use the payment gateway's SDK (e.g., Stripe Java SDK) in the backend.
- Checkout Flow:
- Implement an API endpoint to initiate a checkout session (e.g., Stripe Checkout). This endpoint will take the desired plan ID.
- The frontend will redirect the user to the gateway's hosted checkout page.
- Securely Handle API Keys: Store payment gateway API keys securely (e.g., environment variables, secrets management).
- Customer Creation: Create customers in the payment gateway system and link them to UnravelDocs users.
User Stories:
- As a User, I want to securely enter my payment details on a trusted platform to subscribe to a paid plan.
- As a System, I want to integrate with a payment gateway to handle payment processing and subscription creation.
Acceptance Criteria:
- Payment gateway account is set up with products/prices matching subscription plans.
- Backend API endpoint exists to create a checkout session for a selected plan.
- Users are successfully redirected to the payment gateway's checkout page.
- Payment gateway API keys are securely managed.
- Customers are created in the payment gateway when a user initiates a subscription.
Proposed Technical Details (High-Level - Java/Spring Boot, Stripe context):
- Libraries:
stripe-java
SDK. - Stripe Setup:
- Define Products and Prices in the Stripe Dashboard.
- Obtain API keys (publishable and secret).
- Key Components:
PaymentGatewayService
(e.g.,StripeService
) to encapsulate interactions with Stripe.SubscriptionController
with an endpoint likePOST /api/subscriptions/checkout-session
which takes aplanId
.- This controller calls
StripeService
to create aSession
object usingSessionCreateParams
. - The response includes the Stripe Checkout session ID, which the frontend uses to redirect.
- Configuration: Stripe API keys in
application.properties
or environment variables.
Tasks:
- Choose and set up an account with a payment gateway (e.g., Stripe).
- Define products and prices in the payment gateway dashboard corresponding to UnravelDocs plans.
- Add the payment gateway SDK dependency (e.g.,
stripe-java
) topom.xml
. - Securely configure API keys.
- Implement
PaymentGatewayService
with methods to: - Create/retrieve customers in the gateway.
- Create checkout sessions.
- Implement the API endpoint to initiate the checkout flow.
- Write unit and integration tests (mocking gateway interactions).
- Document the checkout initiation process.
Open Questions/Considerations:
- Payment Methods: Which payment methods will be supported (cards, bank transfers, etc.)? Configure in gateway.
- Tax Collection: How will taxes be handled? (Many gateways offer tools for this).
- Frontend Integration: How will the frontend trigger this and handle the redirect? (This issue focuses on backend).
Metadata
Metadata
Assignees
Labels
UD-ComplexMuch more difficult to implement, requires experience.Much more difficult to implement, requires experience.in progressan issue is being implemented.an issue is being implemented.new featureimplement a new featureimplement a new feature