Complete the code to define the main class for payment processing.
class [1]: def __init__(self): self.transactions = []
The main class handling payments is typically called PaymentProcessor.
Complete the code to add a method that initiates a payment.
def [1](self, amount, method): # code to start payment pass
The method to start a payment is called initiate_payment.
Fix the error in the method that validates payment status.
def validate_status(self, status): if status == [1]: return True return False
The status should be compared as a string literal, so it must be in quotes: "completed".
Fill both blanks to create a dictionary comprehension that maps transaction IDs to amounts for successful payments.
successful_payments = {txn['id']: txn[1] for txn in transactions if txn['status'] [2] 'success'}The dictionary maps transaction IDs to their amounts, so use ['amount']. The filter checks for status equal to 'success', so use ==.
Fill all three blanks to create a method that refunds payments over a certain amount and updates their status.
def refund_large_payments(self, threshold): for txn in self.transactions: if txn['amount'] [1] threshold: self.process_refund(txn[2]) txn['status'] = [3]
The method refunds payments where amount is greater than threshold (>), calls refund with transaction ID (['id']), and sets status to 'refunded'.
