The Square Checkout API does not calculate fees immediately, so this task is
    called to be asynchronously run 1 minute after the initial transaction, so that
    any Invoice or ExpenseItem associated with this transaction also remains accurate.
176202
def updateSquareFees(paymentRecord):
    '''
    
    '''

    fees = paymentRecord.netFees
    invoice = paymentRecord.invoice
    invoice.fees = fees
    invoice.save()
    invoice.allocateFees()
    return fees
101459
async function () {
    const oThis = this
      , brandedToken = new BrandedTokenKlass({ERC20: oThis.erc20Address})
      , isTxHashOnlyNeeded = (oThis.returnType === 'txHash')
    ;

    const r = await brandedToken.approve(
      oThis.approverAddress,
      oThis.approverPassphrase,
      oThis.approveeAddress,
      oThis.toApproveAmount,
      isTxHashOnlyNeeded // we need this to be done in async and not to wait for the tx to get mined.
    );

    return Promise.resolve(r);
  }
481515
private boolean tryEnqueueAttempt(DelayedExecution<T> delayedExecution) {
    int rejectionThreshold = queueRejectionThreshold.get();
    if (rejectionThreshold < 0) {
      return requestQueue.offer(delayedExecution);
    }
    long stamp = stampedLock.readLock();
    try {
      while (requestQueue.size() < rejectionThreshold) {
        long writeStamp = stampedLock.tryConvertToWriteLock(stamp);
        if (writeStamp != 0L) {
          stamp = writeStamp;
          return requestQueue.offer(delayedExecution);
        } else {
          stampedLock.unlock(stamp);
          stamp = stampedLock.writeLock();
        }
      }
      return false;
    } finally {
      stampedLock.unlock(stamp);
    }
  }
1180822
protected boolean hasOngoingTransaction() {
		if(!isSupervisedMode()) {
			return false;
		} else {
			if(ongoingTransactions != null) {
				for (Transaction transaction : ongoingTransactions) {
					if(TransactionState.CALLING.equals(transaction.getState()) ||
						TransactionState.TRYING.equals(transaction.getState()) ||
						TransactionState.PROCEEDING.equals(transaction.getState()) ||
						TransactionState.COMPLETED.equals(transaction.getState()) ||
						TransactionState.CONFIRMED.equals(transaction.getState())) {
							return true;
					}
				}
			}
			return false;
		}
	}
80352
private boolean checkSync() {
        boolean sync = false;
        long last = lastSubmitTime;
        long now = Clock.currentTimeMillis();
        if (last + SYNC_DELAY_MS < now) {
            CONSECUTIVE_SUBMITS.set(this, 0);
        } else if (CONSECUTIVE_SUBMITS.incrementAndGet(this) % SYNC_FREQUENCY == 0) {
            sync = true;
        }
        lastSubmitTime = now;
        return sync;
    }
45996
function(){
					console.log("handleOnlinePrivatePayment queued, will wait for "+key);
					eventBus.once(key, function(bValid){
						if (!bValid)
							return cancelAllKeys();
						assocValidatedByKey[key] = true;
						if (bParsingComplete)
							checkIfAllValidated();
						else
							console.log('parsing incomplete yet');
					});
					cb();
				}
854315
public boolean matchCompleteTransactionTask(long txnId, long timestamp) {
        if (!m_compTasks.isEmpty()) {
            long lowestTxnId = m_compTasks.firstKey();
            if (txnId == lowestTxnId) {
                Pair<CompleteTransactionTask, Boolean> pair = m_compTasks.get(lowestTxnId);
                return timestamp == pair.getFirst().getTimestamp();
            }
        }
        return false;
    }
903867
@Override
	public void setTransactionTimeout(int seconds) throws TransactionManagementException {
		logger.entering(CLASSNAME, "setTransactionTimeout", seconds);
		try {
			userTran.setTransactionTimeout(seconds);
		} catch (SystemException e) {
			throw new TransactionManagementException(e);
		}
		logger.exiting(CLASSNAME, "setTransactionTimeout");
	}
1068119
boolean doWork(long txnId, TransactionTask task)
    {
        boolean retval = canAcceptWork();
        if (!retval) {
            return false;
        }
        MpRoSiteContext site;
        // Repair case
        if (m_busySites.containsKey(txnId)) {
            site = m_busySites.get(txnId);
        }
        else {
            if (m_idleSites.isEmpty()) {
                MpRoSiteContext newSite = new MpRoSiteContext(m_siteId,
                        m_backend,
                        m_catalogContext,
                        m_partitionId,
                        m_initiatorMailbox,
                        m_poolThreadFactory);
                m_idleSites.push(newSite);
                m_allSites.add(newSite);
            }
            site = m_idleSites.pop();
            m_busySites.put(txnId, site);
        }
        site.offer(task);
        return true;
    }
561410
private TransactionStatus computeNewTransactionStatusFromPaymentTransactionInfoPlugin(final PaymentTransactionInfoPlugin input, final TransactionStatus currentTransactionStatus) {
        final TransactionStatus newTransactionStatus = PaymentTransactionInfoPluginConverter.toTransactionStatus(input);
        return (newTransactionStatus != TransactionStatus.UNKNOWN) ? newTransactionStatus : currentTransactionStatus;
    }
13413
private void executeUpdatesAsynchronous(DBTransaction transaction) {
        Collection<BoundStatement> mutations = getMutations(transaction);
        List<ResultSetFuture> futureList = new ArrayList<>(mutations.size());
        for(BoundStatement mutation: mutations) {
            ResultSetFuture future = m_dbservice.getSession().executeAsync(mutation);
            futureList.add(future);
        }
        m_logger.debug("Waiting for {} asynchronous futures", futureList.size());
        for (ResultSetFuture future : futureList) {
            future.getUninterruptibly();
        }
    }
1020009
private void queueOrOfferMPTask(TransactionTask task)
    {
        // The pending map will only have an entry for the transaction if the first fragment is
        // still pending durability.
        Queue<TransactionTask> pendingTasks = m_mpsPendingDurability.get(task.getTxnId());
        if (pendingTasks != null) {
            pendingTasks.offer(task);
        } else {
            m_pendingTasks.offer(task);
        }
    }
674596
public void verify() throws VerificationException {
        final Transaction fromTx = getOutpoint().fromTx;
        long spendingIndex = getOutpoint().getIndex();
        checkNotNull(fromTx, "Not connected");
        final TransactionOutput output = fromTx.getOutput((int) spendingIndex);
        verify(output);
    }
758801
public synchronized boolean isSettlementTransaction(Transaction tx) {
        try {
            tx.verify();
            tx.getInput(0).verify(getContractInternal().getOutput(0));
            return true;
        } catch (VerificationException e) {
            return false;
        }
    }
663985
private boolean shouldProcessTransaction(Action action, long txid) {
        TransactionRequest request = new TransactionRequest(action, txid);
        Integer count;
        if ((count = transactionRequestCount.get(request)) == null) {
            transactionRequestCount.put(request, 1);
            count = 1;
        } else {
            transactionRequestCount.put(request, ++count);
        }
        if (count == checkPointInputTaskCount) {
            transactionRequestCount.remove(request);
            return true;
        }
        return false;
    }
258681
def wait_for_transfer_success(
        raiden: 'RaidenService',
        payment_identifier: PaymentID,
        amount: PaymentAmount,
        retry_timeout: float,
) -> None:
    
    found = False
    while not found:
        state_events = raiden.wal.storage.get_events()
        for event in state_events:
            found = (
                isinstance(event, EventPaymentReceivedSuccess) and
                event.identifier == payment_identifier and
                event.amount == amount
            )
            if found:
                break

        gevent.sleep(retry_timeout)
47267
protected function ProcessStep()
    {
        $continue = parent::ProcessStep();

        $basket = $this->getShopService()->getActiveBasket();
        /**
         * If the user managed to submit the confirmation form twice, we need to avoid handling the second submit.
         * The parent's ProcessStep() method will have delayed the second click until the first request is processed
         * completely by locking the session, so that we can check if the order has already been completed.
         * If yes, we simply forward to the next step (most likely the thank-you page).
         */
        if (0 === $basket->dTotalNumberOfArticles && TdbShopOrderStep::OrderProcessHasBeenMarkedAsCompleted()) {
            $this->JumpToStep($this->GetNextStep());
        }

        // check AGB
        $input = $this->getInputFilterUtil()->getFilteredPostInput('aInput');
        if (false === is_array($input)) {
            $input = array();
        }
        $agb = 'false';
        if (array_key_exists('agb', $input)) {
            $agb = $input['agb'];
        }
        if ('true' !== $agb) {
            $this->getFlashMessages()->addMessage(MTShopBasketCore::MSG_CONSUMER_NAME.'-agb', 'ERROR-CONFIRM-AGB');
            $continue = false;
        }

        $user = $this->getExtranetUserProvider()->getActiveUser();
        $continue = $basket->GetActivePaymentMethod()->processConfirmOrderUserResponse($user, $input) && $continue;

        if ($continue) {
            $this->addDataToBasket($basket);
            // if we fail here, we need to jump back to the current step so any data is rechecked
            if (false === $basket->CreateOrder(MTShopBasketCore::MSG_CONSUMER_NAME)) {
                $this->JumpToStep($this);
            } else {
                $this->PostProcessHookOnOrderCreateSuccess();
            }
        }

        return $continue;
    }