The updateLedger API call is used to update the ledger page for a Vault customer and to provide a corresponding PDF file for the customer to download.
As the table data is a JSON string, it will need to be base64 encoded to prevent certain characters in it from breaking the request JSON.
This is only possible if the user has approved your access.
(see Listing Accounts and Account Details)
data:application/pdf;base64,[base64 encoded file]
{ "action": "updateLedger", "uid": 1001, "pdf": "data:application/pdf;base64,iVBORw0KGgoAA...RU5ErkJggg==", "table": "-- Base64 encoded json formatted string --" }
Success:
{ "error": "", "status": "success", "data": "-- Base64 encoded AES-256-CBC encrypted JSON --", "action": "updateLedger", "version": "1.07", "proc_time": 1651428510, "proc_id": 86 } "data" (decrypted) {}
Failure:
{ "error": "invalid json table data", "status": "failure", "data": "-- Base64 encoded AES-256-CBC encrypted JSON --", "action": "updateLedger", "version": "1.07", "proc_time": 1651428362, "proc_id": 85 } "data" (decrypted) {}
no uid: uid missing
invalid uid: account uid unauthorised or invalid
not approved: The the user hasn't approved your access.
no json table data: table empty or missing
invalid json table data: table is not valid JSON
ledger file is not a PDF: pdf is not a valid PDF file
ledger file size limit exceeded: pdf file is too big
<?php
print_r(request([
'action'=>'updateLedger',
'uid'=>1001,
'pdf'=>'data:application/pdf;base64,'.
base64_encode(
file_get_contents('https://Squidvault.com/testfiles/sample1.pdf')
),
'table'=>base64_encode('[
{
"Date": 1654085840,
"Description": "sale of \"23 O\'Connor St.\"",
"Deposit": 123456.23,
"Payment": "",
"Balance": -123456.23
},
{
"Date": 1654172240,
"Description": ">£100 bracket fees",
"Deposit": "",
"Payment": 456.00,
"Balance": -123000.23
},
{
"Date": 1654258640,
"Description": "partial fee refund",
"Deposit": 50.00,
"Payment": "",
"Balance": -123050.23
},
{
"Date": 1654345040,
"Description": "transfer to \'personal acc\' 23-45-67 98562590",
"Deposit": "",
"Payment": 123456.23,
"Balance": 406.00
}
]')
]));
/*############### OUTPUT ##################
Array(
[error] =>
[status] => success
[data] => {}
[action] => updateLedger
[version] => 1.07
[proc_time] => 1651428510
[proc_id] => 86
)
#########################################*/
?>
Copy Code