44
55namespace Fhp ;
66
7+ use Fhp \Model \PollingInfo ;
78use Fhp \Model \TanRequest ;
9+ use Fhp \Model \VopConfirmationRequest ;
810use Fhp \Protocol \ActionIncompleteException ;
911use Fhp \Protocol \BPD ;
1012use Fhp \Protocol \Message ;
@@ -48,6 +50,12 @@ abstract class BaseAction implements \Serializable
4850 /** If set, the last response from the server regarding this action asked for a TAN from the user. */
4951 protected ?TanRequest $ tanRequest = null ;
5052
53+ /** If set, this action is currently waiting for a long-running operation on the server to complete. */
54+ protected ?PollingInfo $ pollingInfo = null ;
55+
56+ /** If set, this action needs the user's confirmation to be completed. */
57+ protected ?VopConfirmationRequest $ vopConfirmationRequest = null ;
58+
5159 protected bool $ isDone = false ;
5260
5361 /**
@@ -72,15 +80,15 @@ public function serialize(): string
7280 }
7381
7482 /**
75- * An action can only be serialized *after* it has been executed in case it needs a TAN, i.e. when the result is not
76- * present yet .
83+ * An action can only be serialized *after* it has been executed and *if* it wasn't completed yet (e.g. because it
84+ * still requires a TAN or VOP confirmation) .
7785 * If a sub-class overrides this, it should call the parent function and include it in its result.
7886 *
7987 * @return array The serialized action, e.g. for storage in a database. This will not contain sensitive user data.
8088 */
8189 public function __serialize (): array
8290 {
83- if (!$ this ->needsTan ()) {
91+ if (!$ this ->needsTan () && ! $ this -> needsPollingWait () && ! $ this -> needsVopConfirmation () ) {
8492 throw new \RuntimeException ('Cannot serialize this action, because it is not waiting for a TAN. ' );
8593 }
8694 return [
@@ -139,6 +147,26 @@ public function getTanRequest(): ?TanRequest
139147 return $ this ->tanRequest ;
140148 }
141149
150+ public function needsPollingWait (): bool
151+ {
152+ return !$ this ->isDone () && $ this ->pollingInfo !== null ;
153+ }
154+
155+ public function getPollingInfo (): ?PollingInfo
156+ {
157+ return $ this ->pollingInfo ;
158+ }
159+
160+ public function needsVopConfirmation (): bool
161+ {
162+ return !$ this ->isDone () && $ this ->vopConfirmationRequest !== null ;
163+ }
164+
165+ public function getVopConfirmationRequest (): ?VopConfirmationRequest
166+ {
167+ return $ this ->vopConfirmationRequest ;
168+ }
169+
142170 /**
143171 * Throws an exception unless this action has been successfully executed, i.e. in the following cases:
144172 * - the action has not been {@link FinTs::execute()}-d at all or the {@link FinTs::execute()} call for it threw an
@@ -248,4 +276,16 @@ final public function setTanRequest(?TanRequest $tanRequest): void
248276 {
249277 $ this ->tanRequest = $ tanRequest ;
250278 }
279+
280+ /** To be called only by the FinTs instance that executes this action. */
281+ final public function setPollingInfo (?PollingInfo $ pollingInfo ): void
282+ {
283+ $ this ->pollingInfo = $ pollingInfo ;
284+ }
285+
286+ /** To be called only by the FinTs instance that executes this action. */
287+ final public function setVopConfirmationRequest (?VopConfirmationRequest $ vopConfirmationRequest ): void
288+ {
289+ $ this ->vopConfirmationRequest = $ vopConfirmationRequest ;
290+ }
251291}
0 commit comments