WalletService (java)

To get access to the wallet’s funds (to make a deposit, transfer or withdraw) wallet should contain authenticated user’s or Management API Client ID in the holderIds list.
For updating/deleting the wallet, wallet should contain access control object’s ID in the accessControlIds list that contains ID of the client in the write access section. (See examples for more info)

Wallets management

// get list of all accessible wallets Page<Wallet> page = walletService.getAll(); // apply parameters and filter to wallets Filter filter = Filter.lt("balance", 50); Criteria criteria = new Criteria(filter); page = walletService.getAll(criteria, "name", true); // create new wallet Wallet wallet = new Wallet(); wallet.setOwnerId("userId"); wallet.getHolderIds().add("holderId"); wallet.getAccessControlIds().add("accessControlId"); wallet = walletService.create(wallet); // update wallet wallet.setName("name"); walletService.update(wallet); // get wallet wallet = walletService.get(wallet.getId()); // delete wallet walletService.delete(wallet.getId());

Transactions

Wallet wallet1 = walletService.get("walletId1"); Wallet wallet2 = walletService.get("walletId2"); // deposit funds Transaction transaction = new Transaction(); transaction.setAmount("5"); transaction.setCurrency("EUR"); walletService.deposit(wallet1.getId(), transaction); // transfer funds from wallet1 to wallet2 transaction.setAmount("3"); transaction.setTransferTo(wallet2.getId()); walletService.transfer(wallet1.getId(), transaction); // withdraw funds from the wallet transaction.setAmount("2"); walletService.withdraw(wallet1.getId(), transaction);

Examples

// using Management API client TrivoreID id = TrivoreID.mgmtApiClient(); UserServiceImpl userService = new UserServiceImpl(id.userService()); WalletServiceImpl walletService = new WalletServiceImpl(id.walletService()); AccessControlServiceImpl accessControlService = new AccessControlServiceImpl(id.accessControlService()); AccessControl accessControl = new AccessControl(); accessControl.setTitle("Example"); // adding ID of the targer Management API client accessControl.getApiClientIdWrite().add(id.getClientId()); accessControl.getApiClientIdRead().add(id.getClientId()); // getting the owner User owner = userService.get("userId"); Wallet wallet = new Wallet(); wallet.setName("Example Name"); wallet.setCurrency("EUR"); // required field wallet.setOwnerId(owner.getId()); // required field wallet.getAccessControlIds().add(accessControl.getId()); wallet = walletService.create(wallet); // now this Management API has access to modify/delete the wallet wallet = walletService.update(wallet); walletService.delete(wallet.getId());

Wallet Service Models

https://trivore.atlassian.net/wiki/spaces/TISpubdoc/pages/88277458

https://trivore.atlassian.net/wiki/spaces/TISpubdoc/pages/98631789

https://trivore.atlassian.net/wiki/spaces/TISpubdoc/pages/99057677