Transaction History and Details (Unity SDK)

The Transaction History and Transaction Details flows enable users to:

  • See a history of their transactions
  • Explore the details of an individual transaction
  • Email themselves a receipt for an individual transaction

Unity Txn History

Prerequisites

The Transaction History flow requires only an Authorized User Password Token (A User Password Token is a string that enables Tilia Pay to verify that a request belongs to an authorized session). From the history page, a user can navigate between individual Transaction Details pages.

If you would like to direct a user to a specific Transaction Details page, you will need both:

  • An Authorized User Password Token
  • The Transaction ID that corresponds to that transaction
note

All methods and flows in the Tilia SDK require you to have a server setup that communicates with Tilia’s APIs (your server will have a private api key which needs to remain secure and should never be exposed to client-side applications). Your client application should communicate with your own api (ensuring user authentication) to retrieve data required by the Tilia SDK.

Server-Side Code Example to Retrieve User Access Token

  • Requires your server to retrieve a client credentials access token. See more here .
  • Requires an account id for a user that has been registered with Tilia. See more here .
Copy
Copied
curl -i -X POST \
  https://auth.staging.tilia-inc.com/authorize/user \
  -H 'Authorization: Bearer <CLIENT_CREDENTIALS_ACCESS_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "account_id": "<USER_ACCOUNT_ID_HERE>",
    "return_token": true,
  }'

Example Responce Payload

Copy
Copied
{
    "status": "Success",
    "message": [],
    "codes": [],
    "payload": {
        "token": {
            "access_token": "USER_PASSWORD_TOKEN",
            "token_type": "Bearer",
            "refresh_token": "REFRESH_TOKEN",
            "expiry": "TOKEN_EXPIRATION"
        }
    }
}

C# Code Examples

These code snippets are an example of how to execute the Transaction History or Details Flow from inside your own code.

  • These example assumes that your code contains a variable called TiliaManager that is a valid reference to a TiliaUIManager class that is active in your Unity scene (part of the standard Tilia Canvas Group).
  • TiliaUIMessages.Message is a static function that assumes you have the TiliaUIMessages class active in your Unity scene (part of the standard Tilia Canvas Group).

Transaction History Example

Copy
Copied
public void DoHistoryFlow()
{
    TiliaManager.HistoryFlow((result) =>
    {
        // Completed
        // result is a TiliaEvent class
		// User clicked the "Close" button.
        TiliaUIMessages.Message("The user has closed the transaction history.");
    },
    (result) => {
        // Canceled
        // result is a TiliaEvent class
        TiliaUIMessages.Message("The user canceled the transaction history flow.");
    },
    (result) =>
    {
        // Error
		// result is a TiliaEvent class
        // result.Payload is an object of TiliaTransactionHistory type which includes API error data such as the web server response code and any API specific messages.
        TiliaUIMessages.Message("There was an error while attempting to execute transaction history flow.");
    });
}

Transaction Details Example

Copy
Copied
public void DoReceiptFlow(string transactionID)
{
	// transactionID here as an input to ReceiptFlow must be a valid string.
    TiliaManager.ReceiptFlow(transactionID,
    (result) =>
    {
        // Completed
        // result is a TiliaEvent class
		// User clicked the "Close" button.
        TiliaUIMessages.Message("The user has closed the receipt.");
    },
    (result) => {
        // Canceled
        // result is a TiliaEvent class
        TiliaUIMessages.Message("The user canceled the receipt flow.");
    },
    (result) =>
    {
        // Error
		// result is a TiliaEvent class
        // result.Payload is an object of TiliaResponse type which includes API error data such as the web server response code and any API specific messages.
        TiliaUIMessages.Message("There was an error while attempting to execute receipt flow.");
    });
}