Attempt to rewrite https://github.com/aniarosner/payments-ddd in a modular way
Initially started using ActiveSupport::Notifications as EventBus,
later was replaced by Kafka, which allows to move domains to separate processes.
docker-compose up -d
bundle install
cp .env.template .env # and modify it!
./bin/rails kafka_topics:create db:create db:migrate
bundle exec karafka server # in a separate tab
./bin/rails db:seedUserOrders.new(2).getSupport::Data.seed_db(if you want to do it manually via console)Support::Data.run_cron_jobs
- marks all the payments created more than 20 min ago and still not "authorized" as "authorization_failed"
- marks all the "authorized" payments with "authorization_expires_at" <= NOW as "authorization_expired"
- name
- current_price
- available_quantity
- has_many :order_lines
- has_one :shipping_info
- has_one :contact_info
- has_one :payment
- status
State machine:
placed ->submitted
then we try to reserve the required quantity,
if failure - cancelled, we then display this to user with a "modify order" button, which is "place_order?retry_order_id=123",
e.g. he'll create a new order but FE will show him pre-filled fields from previous one
if success -> accepted, schedule a job to cancel the order in 30 min and try to authorize required amount
if authorization is successful - we ship the order and mark it as shipped,
if authorization failure - display "retry payment" and "modify order"(e.g. cancel order and redirect to "place_order?retry_order_id=123") buttons
- order_id
- product_id
- quantity
- price_at_submit
- order_id
- receiver_name
- shipping_address
- order_id
- phone
- order_id
- currency ??
- amount
- transaction_identifier
- status
