Who Sets The Next State

A reviewer labels this "Strategy: the order delegates to a swappable policy object".

class Order:
    def __init__(self):     self.handler = Draft(self)
    def submit(self):       self.handler.submit()
    def pay(self):          self.handler.pay()

class Draft:
    def __init__(self, order): self.order = order
    def submit(self):          self.order.handler = AwaitingPayment(self.order)
    def pay(self):             raise Invalid("submit first")

class AwaitingPayment:
    def __init__(self, order): self.order = order
    def submit(self):          raise Invalid("already submitted")
    def pay(self):             self.order.handler = Paid(self.order)

class Paid:
    def __init__(self, order): self.order = order
    def submit(self):          raise Invalid("already paid")
    def pay(self):             raise Invalid("already paid")

Which pattern is it, and which single line settles the question?

A

Chain of Responsibility. Draft.pay declines to handle the request, which is a handler passing it along.

B

State. The line self.order.handler = AwaitingPayment(self.order) has one concrete handler naming and installing the next one, which is the dependency Strategy forbids and State permits.

C

Strategy. The context varies its behavior by delegating to an interchangeable object, which is the entire definition; State is the same structure under a different name.

D

Command. Each class packages an operation as an object, so the context could queue, log or undo submit and pay.