Skip to content

Post bank transaction

Posts a provisional bank transaction: it becomes final. This cannot be undone: a final transaction can no longer be changed or deleted, only corrected with another transaction. So this example only posts the transaction you pass on the command line, and without arguments it only explains itself.

Twinfield documentation: Bank transactions.

post($dayBook, $number) sends <transaction action="post">. Twinfield refuses transactions that are already final, which is thrown as ProcessXmlException; the example checks the status first.

$twinfield = Example::twinfield();
if (!isset($argv[1], $argv[2])) {
echo 'Pass a bank book and the number of a provisional transaction, e.g. BNK 202600045.', PHP_EOL;
echo 'Posting cannot be undone: a final transaction cannot be changed or deleted.', PHP_EOL;
exit(0);
}
$bank = $twinfield->bankTransactions();
$transaction = $bank->get($argv[1], (int) $argv[2]);
if (!$transaction->header->isProvisional()) {
echo $transaction->dayBook(), ' ', $transaction->number(), ' is already final.', PHP_EOL;
exit(0);
}
$bank->post($transaction->dayBook(), $transaction->number());
echo 'Posted ', $transaction->dayBook(), ' ', $transaction->number(), ': ',
$bank->get($transaction->dayBook(), $transaction->number())->header->status->name, PHP_EOL;
Terminal window
php examples/bank-transactions/post-bank-transaction/example.php BNK 202600045
Posted BNK 202600045: Final

What the SDK sends to Twinfield and what Twinfield sends back, for a call like the one in this example. The responses come from the tests, with example data.

Twinfield documentation: Bank transactions: Post.

$twinfield->bankTransactions()->post('BNK', 202600046);

The SDK sends this XML as xmlRequest of ProcessXmlString to processxml.asmx:

<transaction action="post">
<office>1000</office>
<code>BNK</code>
<number>202600046</number>
</transaction>

Twinfield answers with this XML in ProcessXmlStringResult:

<transaction action="post" result="1">
<office>1000</office>
<code>BNK</code>
<number>202600046</number>
</transaction>

View examples/bank-transactions/post-bank-transaction/example.php on GitHub.

Made by SolveBeam

Twinfield and Wolters Kluwer are trademarks of Wolters Kluwer. Their names and logos are used only to refer to their products.