wiki:UseCase06

Version 1 (modified by 181201, 4 hours ago) ( diff )

--

Use-case 0006 - Process a Payment

Initiating actor: Pet Owner

Other actors: None

Description: The owner must pay for a confirmed booking. The system finds unpaid bookings for that user, and the owner submits their payment method. The system records the financial transaction and links it securely to the booking.

Scenario:

  1. Pet Owner navigates to their "Pending Payments" dashboard.
  2. System fetches confirmed bookings that do not have a matching payment record yet using a LEFT JOIN:
    SELECT b.booking_id, b.address, b.date_from 
    FROM bookings b
    LEFT JOIN payments p ON b.booking_id = p.booking_id
    WHERE b.owner_id = (SELECT user_id FROM users WHERE username = 'owner_bojan')
      AND b.status = 'CONFIRMED'
      AND p.payment_id IS NULL;
    
  3. Owner selects a booking, chooses 'CREDIT_CARD', and submits the payment.
  4. System securely records the payment in the database, satisfying the 1:1 relationship rule:
    INSERT INTO payments (amount, payment_type, booking_id)
    VALUES (
        1500, 
        'CREDIT_CARD',
        (SELECT booking_id FROM bookings WHERE address = 'ul. Partizanska br. 10' LIMIT 1)
    );
    
Note: See TracWiki for help on using the wiki.