Ejemplo n.º 1
0
 private long tryCreateAccounts(long userId) throws Exception {
   CreateAccountRequest req = new CreateAccountRequest();
   req.setNegativeBalanceAllowed(false);
   req.setRequestId(UUID.randomUUID());
   req.setUserId(userId);
   req.setCurrencyCode(currency);
   req.setType(STATIC_ACCOUNT);
   req.setNegativeBalanceAllowed(true); // Bots are allowed negative amounts
   MetaInformation inf = new MetaInformation();
   inf.setName("User " + userId + " Main Account");
   req.setInformation(inf);
   WalletServiceClientHTTP client = new WalletServiceClientHTTP(walletService);
   return client.createAccount(req).getAccountId();
 }
Ejemplo n.º 2
0
 private long tryInitialAmount(long accountId, long userId) throws Exception {
   if (balance > 0) {
     WalletServiceClientHTTP client = new WalletServiceClientHTTP(walletService);
     TransactionRequest req = new TransactionRequest();
     Money credit = new Money(currency, 2, new BigDecimal(String.valueOf(balance)));
     req.getEntries().add(new TransactionEntry(accountId, credit));
     Account acc = client.getAccount(bankaccount, currency);
     req.getEntries().add(new TransactionEntry(acc.getId(), credit.negate()));
     req.setComment("initial balance for user " + userId);
     return client.doTransaction(req).getTransactionId();
   } else {
     return -1;
   }
 }