Skip to content

feat: Implement payment service with Stripe integration - #6

Merged
rezadrian01 merged 6 commits into
mainfrom
feature/payment-service
May 28, 2026
Merged

feat: Implement payment service with Stripe integration#6
rezadrian01 merged 6 commits into
mainfrom
feature/payment-service

Conversation

@rezadrian01

Copy link
Copy Markdown
Owner

Summary

  • Full payment service implementation (port 8084) with Stripe PaymentIntents integration
  • Kafka consumer subscribes to order.created → creates Stripe PaymentIntent → stores Payment record
  • Webhook handler processes payment_intent.succeeded/payment_failed/processing events and publishes payment.created/completed/failed Kafka events
  • Redis cache-aside for payment lookups (1h TTL)
  • Fixed pre-existing docker-compose bug: kafka, zookeeper, and kafka-ui were missing networks: auron-network, making them unreachable from all microservices

Changes

New service — services/payment-service/

  • Domain layer: Payment entity, PaymentStatus, OrderCreatedEvent, repository/service/cache/events/stripe client interfaces, 5 sentinel errors
  • DB migration: payments table with status CHECK constraint, amount > 0 CHECK, unique index on order_id
  • Repository: 5 GORM methods; UpdatePaymentStatus and UpdateStripeIDs as separate operations
  • Cache: payment:<uuid> key, 1h TTL
  • Kafka publisher: writes to payment.created, payment.completed, payment.failed
  • Kafka consumer: reads order.created (group payment-service); idempotent via GetPaymentByOrderID check
  • Stripe client: wraps stripe-go/v76; converts amount to cents; passes payment_id/order_id/user_id as Stripe metadata
  • Service: client_secret only travels via payment.created Kafka event, never HTTP; webhook verification bypassed when STRIPE_WEBHOOK_SECRET is empty (dev)
  • Raw body middleware: captures request bytes before binding for Stripe signature verification
  • cmd bootstrap: full wiring with context.WithCancel for clean consumer shutdown on SIGTERM

docker-compose.yml

  • Added REDIS_URL, KAFKA_BROKERS, STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET to payment-service
  • Added kafka: condition: service_healthy to payment-service.depends_on
  • Added networks: - auron-network to zookeeper, kafka, kafka-ui (bug fix)

Test plan

  • docker-compose up payment-service payments-db redis kafka starts without errors
  • GET /health returns {"status":"healthy","service":"payment-service"}
  • POST /api/payments/webhook/stripe with a valid Stripe test event returns 200
  • GET /api/payments/:id with a valid auth token returns the payment or 404
  • Creating an order triggers order.created → payment-service creates a PaymentIntent and publishes payment.created
  • Stripe payment_intent.succeeded webhook updates payment status to completed and publishes payment.completed

🤖 Generated with Claude Code

rezadrian01 and others added 6 commits May 28, 2026 11:24
…tion

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…che layers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… and handler layers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nd env files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…a/zookeeper/kafka-ui

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…struct

The order-service publishes the Order struct directly which uses json:"id"
for the order ID field. The consumer struct had json:"order_id" which would
leave OrderID as uuid.Nil after unmarshaling, breaking Stripe intent creation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 28, 2026 08:54
@rezadrian01
rezadrian01 merged commit a7b89d7 into main May 28, 2026
1 of 2 checks passed
@rezadrian01
rezadrian01 removed the request for review from Copilot May 28, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant