Enables auto recharges.

@param integer $whenCredit Autorecharge when credit reaches this amount.
@param float $total Total credits to autorecharge.

@return PortaText\Command\ICommand
767718
public function enableAutoRecharges($whenCredit, $total)
    {
        $this->setArgument("autorecharge_enabled", true);
        $this->setArgument("autorecharge_total", $total);
        return $this->setArgument("autorecharge_when_credit", $whenCredit);
    }
982674
public function setAutoOnPaymentMethod($accountID, $paymentMethodID, $auto)
    {
        return $this->httpHelper->patch("/accounts/" . intval($accountID) . "/payment_methods/" . intval($paymentMethodID) . "/toggle_auto", [
            'auto' => (boolean)$auto
        ]);
    }
463162
public function creditCardCheck(PayoneCreditCardTransfer $creditCardData)
    {
        /** @var \SprykerEco\Zed\Payone\Business\Payment\MethodMapper\CreditCardPseudo $paymentMethodMapper */
        $paymentMethodMapper = $this->getRegisteredPaymentMethodMapper($creditCardData->getPayment()->getPaymentMethod());
        $requestContainer = $paymentMethodMapper->mapCreditCardCheck($creditCardData);

        $this->setStandardParameter($requestContainer);

        $rawResponse = $this->executionAdapter->sendRequest($requestContainer);
        $responseContainer = new CreditCardCheckResponseContainer($rawResponse);

        $responseMapper = new CreditCardCheckResponseMapper();
        $responseTransfer = $responseMapper->getCreditCardCheckResponseTransfer($responseContainer);

        return $responseTransfer;
    }
846474
public static function persistTransaction($transaction, $transactionPartsDebit, $transactionPartsCredit) {
        if ($transaction->hash === null) {
            $transaction->hash = TransactionPersistance::hashTransaction($transaction);
        }
        
        if (count($transactionPartsDebit)<1 || count($transactionPartsCredit)<1) {
            throw new Exception("transactionPartsDebit (" . count($transactionPartsDebit) . " elements) or transactionPartsCredit (" . count($transactionPartsCredit) . " elements) empty");
        }
        
        $transaction->validate();
        Model::validateMultiple($transactionPartsDebit);
        Model::validateMultiple($transactionPartsCredit);

        if (count($transaction->errors) > 0) {
            throw new Exception('Transaction validation errors: ' . print_r($transaction->errors,true));
        }
        foreach ($transactionPartsDebit as $tp) {
            if (count($tp->errors) > 0) {
                throw new Exception('TransactionPartsDebit validation errors: ' . print_r($tp->errors,true));
            }
        }
        foreach ($transactionPartsCredit as $tp) {
            if (count($tp->errors) > 0) {
                throw new Exception('TransactionPartsCredit validation errors: ' . print_r($tp->errors,true));
            }
        }
        
        //Check sums
        $sumDebit = 0;
        $debitAccounts = [];
        foreach ($transactionPartsDebit as $tp) {
            $sumDebit = StaticEb::mathAdd($tp->value,$sumDebit);
            array_push($debitAccounts,$tp->account_id);
        }

        $sumCredit = 0;
        foreach ($transactionPartsCredit as $tp) {
            if (in_array($tp->account_id,$debitAccounts)) {
                throw new Exception("Account ID " . $tp->account_id . " in debit and credit side.");
            }

            $sumCredit = StaticEb::mathAdd($tp->value,$sumCredit);
        }

        if ($sumCredit != $sumDebit || $sumDebit != $transaction->value || $sumCredit != $transaction->value ) {
            throw new Exception("Values of transaction (" . $transaction->value . "), debit side (" . $sumDebit . ") credit side (" . $sumCredit .") not equal.");
        }

        
        
        $dbTransaction = \Yii::$app->db->beginTransaction();
        try {
            if (!$transaction->save(false)) {
                $dbTransaction->rollBack();
                throw new Exception("Transaction could not be saved. Data: " . print_r($transaction->attributes,true));
            }
                     
            foreach ($transactionPartsDebit as $tp) {
                TransactionPersistance::persistTransactionPart($tp,$transaction->transaction_id);
            }

            foreach ($transactionPartsCredit as $tp) {
                TransactionPersistance::persistTransactionPart($tp,$transaction->transaction_id);
            }

            $dbTransaction->commit();
        } catch (Exception $e) {
            $dbTransaction->rollBack();
            throw $e;
        }

        return $transaction->transaction_id;
    }
1244151
public function setTotalUnreadCount($totalUnreadCount)
    {

        if (!is_null($totalUnreadCount) && ($totalUnreadCount < 0)) {
            throw new \InvalidArgumentException('invalid value for $totalUnreadCount when calling GetCharactersCharacterIdMailLabelsOk., must be bigger than or equal to 0.');
        }

        $this->container['totalUnreadCount'] = $totalUnreadCount;

        return $this;
    }
434308
public function total($count)
    {
        if ($this->get) {
            $this->total = ($count > $this->limit) ? ceil($count / $this->limit) : 1;
        }
    }
125341
private function computeTotalCount($total, array $callableArgs = [])
    {
        if (null !== $this->totalCount) {
            return $this->totalCount;
        }

        $this->totalCount = \is_callable($total) ? \call_user_func_array($total, $callableArgs) : $total;

        return $this->totalCount;
    }
128042
public function limit($total, $offset = 0)
    {
        $this->_limit = $total;
        $this->_offset = $offset;
        return $this;
    }
968431
public function onCharge($order)
    {
        if (!isset($this->omnipay))
            throw new ShopException('Omnipay gateway not set.', 0);

        try {

            $response = $this->omnipay->purchase(array_merge([
                'amount'    => $order->total,
                'currency'  => Config::get('shop.currency'),
                'card'      => $this->isCreditCard ? $this->creditCard : [],
                'returnUrl' => $this->callbackSuccess,
                'cancelUrl' => $this->callbackFail,
            ], $this->options))->send();

            if ($response->isSuccessful()) {

                $this->transactionId = $response->getTransactionReference();

                $this->detail = 'Success';


            } elseif ($response->isRedirect()) {

                $this->statusCode = 'pending';

                $this->approvalUrl = $response->getRedirectUrl();

                $this->detail = sprintf('Pending approval: %s', $response->getRedirectUrl());

            } else {

                throw new GatewayException($response->getMessage(), 1);

            }

            return true;

        } catch (Exception $e) {

            throw new ShopException(
                $e->getMessage(),
                1000,
                $e
            );

        }

        return false;
    }
1073538
public function charge($amount = null)
    {
        return (new AuthorizationBuilder(TransactionType::SALE, $this))
                        ->withAmount($amount)
                        ->withOneTimePayment(true);
    }
1274840
public function beginTransaction( $autoCommit = 1 )
	{
		$this->openTransactions ++;
		if( $this->openTransactions == 1 )
		{
			if( $autoCommit )
			{
				$query = "SET AUTOCOMMIT=0";
			}
			$this->Execute( $query );
			$query = "START TRANSACTION";
			$this->Execute ($query);
		}
	}
809203
private <T> CompletableFuture<T> executeCommandAsyncWithInjectedTx(InvocationContext ctx, VisitableCommand command) {
      CompletableFuture<T> cf;
      final Transaction implicitTransaction;
      try {
         // interceptors must not access thread-local transaction anyway
         implicitTransaction = transactionManager.suspend();
         assert implicitTransaction != null;
         //noinspection unchecked
         cf = (CompletableFuture<T>) invoker.invokeAsync(ctx, command);
      } catch (SystemException e) {
         throw new CacheException("Cannot suspend implicit transaction", e);
      } catch (Throwable e) {
         tryRollback();
         throw e;
      }
      return cf.handle((result, throwable) -> {
         if (throwable != null) {
            try {
               implicitTransaction.rollback();
            } catch (SystemException e) {
               log.trace("Could not rollback", e);
               throwable.addSuppressed(e);
            }
            throw CompletableFutures.asCompletionException(throwable);
         }
         try {
            implicitTransaction.commit();
         } catch (Exception e) {
            log.couldNotCompleteInjectedTransaction(e);
            throw CompletableFutures.asCompletionException(e);
         }
         return result;
      });
   }
170312
function initCompleteTransaction($amount, $buyOrder, $sessionId, $cardExpirationDate, $cvv, $cardNumber) {

        try {

            $wsCompleteInitTransactionInput = new wsCompleteInitTransactionInput();
            $completeCardDetail = new completeCardDetail();
            $wsCompleteTransactionDetail = new wsCompleteTransactionDetail();

            /** (Obligatorio) Indica el tipo de transacción, su valor debe ser siempre TR_COMPLETA_WS */
            $wsCompleteInitTransactionInput->transactionType = 'TR_COMPLETA_WS';
            $wsCompleteInitTransactionInput->sessionId = $sessionId;

            $wsCompleteTransactionDetail->amount = $amount;
            $wsCompleteTransactionDetail->buyOrder = $buyOrder;
            $wsCompleteTransactionDetail->commerceCode = $this->config->getCommerceCode();

            $completeCardDetail->cardExpirationDate = $cardExpirationDate;
            $completeCardDetail->cvv = $cvv;
            $completeCardDetail->cardNumber = $cardNumber;

            /** (Obligatorio) Objeto del tipo wsTransactionDetail que contiene información asociada a la tarjeta de crédito */
            $wsCompleteInitTransactionInput->cardDetail = $completeCardDetail; // cardDetails

            /** (Obligatorio) Lista de objetos del tipo wsTransactionDetail, el cual contiene datos de la transacción. Máxima cantidad de repeticiones es de 1 para este tipo de transacción */
            $wsCompleteInitTransactionInput->transactionDetails = $wsCompleteTransactionDetail; // wsTransactionDetail

            $initCompleteTransactionResponse = $this->_initCompleteTransaction(
                    array("wsCompleteInitTransactionInput" => $wsCompleteInitTransactionInput)
            );

            $xmlResponse = $this->soapClient->__getLastResponse();
            $soapValidation = new SoapValidation($xmlResponse, $this->config->getWebpayCert());
            $validationResult = $soapValidation->getValidationResult();

            if ($validationResult === TRUE) {

                $wsCompleteInitTransactionOutput = $initCompleteTransactionResponse->return;
                return $wsCompleteInitTransactionOutput;
            } else {

                $error["error"] = "Error validando conexi&oacute;n a Webpay (Verificar que la informaci&oacute;n del certificado sea correcta)";
                $error["detail"] = "No se pudo completar la conexi&oacute;n con Webpay";
            }
        } catch (Exception $e) {

            $error["error"] = "Error conectando a Webpay (Verificar que la informaci&oacute;n del certificado sea correcta)";

            $replaceArray = array('<!--' => '', '-->' => '');
            $error["detail"] = str_replace(array_keys($replaceArray), array_values($replaceArray), $e->getMessage());
        }

        return $error;
    }
1140418
public function onCheckout($cart)
    {
        if (!isset($this->omnipay))
            throw new ShopException('Omnipay gateway not set.', 0);

        if ($this->isCreditCard && !isset($this->creditCard))
            throw new GatewayException('Credit Card not set.', 1);
        try {

            $response = $this->omnipay->authorize(array_merge([
                'amount'    => $cart->total,
                'currency'  => Config::get('shop.currency'),
                'card'      => $this->isCreditCard ? $this->creditCard : [],
                'returnUrl' => $this->callbackSuccess,
            ], $this->options))->send();

            if (!$response->isSuccessful()) {
                throw new CheckoutException($response->getMessage(), 1);
            }

        } catch (Exception $e) {

            throw new CheckoutException(
                'Exception caught while attempting authorize.' . "\n" . 
                $e->getMessage(),
                1
            );
        }
    }
451783
public function setAutoIncrement(int $value)
    {
        if (!$key = $this->autoIncrement()) {
            throw new \Exception('Autoincrement not defined for table `' . $this->name() . '`.');
        }

        $this[$key] = $value;

        return $this;
    }
133608
public function setCardExpMonth($sCardExpMonth)
    {
        //  Validate
        if (is_numeric($sCardExpMonth)) {

            $iMonth = (int) $sCardExpMonth;
            if ($iMonth < 1 || $iMonth > 12) {

                throw new ChargeRequestException(
                    '"' . $sCardExpMonth . '" is an invalid expiry month; must be in the range 1-12.',
                    1
                );

            } else {
                $this->oCard->exp->month = $iMonth < 10 ? '0' . $iMonth : (string) $iMonth;
                return $this;
            }

        } else {
            throw new ChargeRequestException(
                '"' . $sCardExpMonth . '" is an invalid expiry month; must be numeric.',
                1
            );
        }
    }
788655
public function addOutgoingPaymentRequest(
        string $payerNr,
        SEK $amount,
        \DateTimeInterface $date,
        string $ref,
        string $interval,
        int $repetitions
    ): void {
        $this->addPaymentRequest(
            'OutgoingPaymentRequest',
            $payerNr,
            $amount,
            $date,
            $ref,
            $interval,
            $repetitions
        );
    }