As far as using webhooks goes, you only really need one method called decrypt. It's available in the Piano PHP SDK, Java SDK, and Python SDK. Naming conventions are similar across those three options, but if you're using the PHP SDK, you can find it under the TPSecurityUtils class.
Here is a small code snippet that you can use to get the data from the webhook via our PHP SDK.
<?php
$aid = "insert_AID";
$apiToken = "insert_API_token";
/*Insert the correct private key here */
$privateKey = "XXXXXX";
$webhookdata = "29Wbzug1JCkmvTi_7Sg72LkHL8zqiAdEK77GE2F3mOEPVH9-U3bYb9_HS5YuJo4zGvb3Dgn4F2bd1TjRMg1qnSqpQEgv0p71QMYk8jnon4bgny-UxziByxsMJxZ125FT931D5E6V9UmgK_66MfzEejHUjooA7ogKzD4wM5U-zw8u6XJLXRI3hP4_IaEuBYFqGgnqIFtUq8ugH4A_USO1pR4NxjkedgOi4il-zoTbkRzoW4EPFs4ekQM8l9vY92zen-aswg9-wma8fUzMvMQfNQ~~~JFSKlpPmv3fqJgipzivZZGhF5e-q4BYFFpPiSRhBUZY";
/*Include Piano SDK - make sure to use the correct path */
require_once ("php/TinypassClient.php");
$tinypassConfig = new TPConfig( $aid, $apiToken, $privateKey, "true" );
$tinypassClient = new TinypassClient($tinypassConfig);
$webhookdecrypt = new Webhook;
$var = $webhookdecrypt::parse($webhookdata, $privateKey);
print_r ($var);
?>
Please also make sure that the PHP SDK is unzipped and in the same folder as described in the code.
The data returned looks like this, which you can then use to make any API call you may need, to get any other necessary information you're looking for.
{"version": 2,"type": "access_granted","event": "new_purchase","aid": "123ABC","expires": 1505534399,"access_id": "yreXceZMxBGX","term_id": "TM061LNL9TM5","rid": "RQABZ8F","uid": "XYZ"}
You can't go very granular with the time frame. Even if you specify a time window using a Unix Timestamp, it's always going to show a full day's worth at minimum, so a specified time window less than a day will not return the results you're looking for.
If needed, you can use our Python SDK and decrypt the webhook like this:
from pianosdk import Client, AccessTokenStorage
client = Client(api_host='sandbox', api_token='TOKEN', private_key='PRIVATE_KEY')
response = client.parse_webhook_data('WEBHOOK_DATA')
print(f'Webhook event: [{type(response)}] {response}')