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,16 +80,16 @@ 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 * Note that this is not necessarily valid UTF-8, so you should store it as a BLOB column or raw bytes.
8189 */
8290 public function __serialize (): array
8391 {
84- if (!$ this ->needsTan ()) {
92+ if (!$ this ->needsTan () && ! $ this -> needsPollingWait () && ! $ this -> needsVopConfirmation () ) {
8593 throw new \RuntimeException ('Cannot serialize this action, because it is not waiting for a TAN. ' );
8694 }
8795 return [
@@ -140,6 +148,26 @@ public function getTanRequest(): ?TanRequest
140148 return $ this ->tanRequest ;
141149 }
142150
151+ public function needsPollingWait (): bool
152+ {
153+ return !$ this ->isDone () && $ this ->pollingInfo !== null ;
154+ }
155+
156+ public function getPollingInfo (): ?PollingInfo
157+ {
158+ return $ this ->pollingInfo ;
159+ }
160+
161+ public function needsVopConfirmation (): bool
162+ {
163+ return !$ this ->isDone () && $ this ->vopConfirmationRequest !== null ;
164+ }
165+
166+ public function getVopConfirmationRequest (): ?VopConfirmationRequest
167+ {
168+ return $ this ->vopConfirmationRequest ;
169+ }
170+
143171 /**
144172 * Throws an exception unless this action has been successfully executed, i.e. in the following cases:
145173 * - the action has not been {@link FinTs::execute()}-d at all or the {@link FinTs::execute()} call for it threw an
@@ -249,4 +277,16 @@ final public function setTanRequest(?TanRequest $tanRequest): void
249277 {
250278 $ this ->tanRequest = $ tanRequest ;
251279 }
280+
281+ /** To be called only by the FinTs instance that executes this action. */
282+ final public function setPollingInfo (?PollingInfo $ pollingInfo ): void
283+ {
284+ $ this ->pollingInfo = $ pollingInfo ;
285+ }
286+
287+ /** To be called only by the FinTs instance that executes this action. */
288+ final public function setVopConfirmationRequest (?VopConfirmationRequest $ vopConfirmationRequest ): void
289+ {
290+ $ this ->vopConfirmationRequest = $ vopConfirmationRequest ;
291+ }
252292}
0 commit comments