Captures a charge.

@return OmiseCharge
774154
public function capture()
    {
        $result = parent::execute(self::getUrl($this['id']).'/capture', parent::REQUEST_POST, parent::getResourceKey());
        $this->refresh($result);

        return $this;
    }
249396
public function getAmount()
    {
        if ($this->isStatusExceptional()) {
            return (string)($this->getData()->getBtcPrice() * $this->getData()->getRate());
        }

        return (string)$this->data->getPrice();
    }
553016
private function chargeNew($capture) {return dfc($this, function($capture) {
		$fc = $this->fCharge(); /** @var fCharge $fc */
		/**
		 * 2017-06-11
		 * Some PSPs like Moip require 2 steps to make a payment:
		 * 1) Creating an «order».
		 * 2) Creating a «payment».
		 * To implement such a scheme, the @uses \Df\StripeClone\P\Charge::request()
		 * should return data for the both requests,
		 * and then @uses \Df\StripeClone\Facade\Charge::create() should make the both requests.
		 */
		/** @var array(string => mixed) $preorderParams */
		if ($needPreorder = $fc->needPreorder() /** @var bool $needPreorder */) {
			$preorderParams = pPreorder::request($this);
			df_sentry_extra($this, 'Preorder Params', $preorderParams);
			$fc->preorderSet(fPreorder::s($this)->create($preorderParams));
		}
		$p = pCharge::request($this, $capture); /** @var array(string => mixed) $p */
		df_sentry_extra($this, 'Request Params', $p);
		$result = $fc->create($p); /** @var object|array(string => mixed) $result */
		if ($this->isCard()) {
			/**
			 * 2017-07-24
			 * Unfortunately, the one-liner fails on PHP 5.6.30:
			 * $this->iiaAdd((CardFormatter::s($this, $fc->card($result)))->ii());
			 * «syntax error, unexpected '->' (T_OBJECT_OPERATOR)»
			 * https://github.com/mage2pro/core/issues/15
			 * See also: https://github.com/mage2pro/core/issues/16
			 *
			 * 2017-07-31
			 * Interestingly, the following code works on all PHP versions >= 5.4.0:
			 * class A {function f() {return __METHOD__;}
			 * echo (new A)->f();
			 * https://3v4l.org/nANqg
			 *
			 * The following code works on all PHP versions >= 5.0.0:
			 *	class A {
			 *		function f() {return __METHOD__;}
			 *		static function s() {return new self;}
			 *	}
			 *	echo A::s()->f();
			 * https://3v4l.org/1qr48
			 *
			 * The same is true for the following code:
			 *	class A {
			 *		function f() {return $this->_v;}
			 *		final protected function __construct($v) {$this->_v = $v;}
			 *		private $_v;
			 *		final static function s($v) {return new self($v);}
			 *	}
			 *	echo A::s('test')->f();
			 * https://3v4l.org/2E8H6
			 *
			 * So, I was unable to reproduce the issue...
			 * Maybe the problem customer uses a non-standard (patched) PHP version?
			 *
			 * 2017-11-08
			 * Note 1.
			 * One-liners like (!($e = $a->e())->b()) are really not supported by PHP < 7:
			 * https://3v4l.org/lJjvS
			 * Note 2.
			 * At the same time, some `))->` one-liners are supported by PHP >= 5.4, e.g:
			 * static function p() {return (new self())->b();}
			 * https://3v4l.org/LJlDE
			 * Note 3.   
			 * If we add extra brackets to the code from the Note 2,
			 * then the code will be incompatible with PHP < 7:
			 * static function p() {return ((new self()))->b();}
			 */
			$cf = CardFormatter::s($this, $fc->card($result)); /** @var CardFormatter $cf */
			$this->iiaAdd($cf->ii());
		}
		$this->transInfo($result, $p + (!$needPreorder ? [] : ['df_preorder' => $preorderParams]));
		$needRedirect = $this->redirectNeeded($result); /** @var bool $needRedirect */
		$i = $this->ii(); /** @var II|OP|QP $i */
		/**
		 * 2016-03-15
		 * Иначе операция «void» (отмена авторизации платежа) будет недоступна:
		 * «How is a payment authorization voiding implemented?»
		 * https://mage2.pro/t/938
		 * https://github.com/magento/magento2/blob/2.1.0/app/code/Magento/Sales/Model/Order/Payment.php#L540-L555
		 * @used-by \Magento\Sales\Model\Order\Payment::canVoid()
		 *
		 * 2016-12-16
		 * Раньше мы окончание не добавляли, и это приводило к проблеме https://mage2.pro/t/2381
		 * При Refund из интерфейса Stripe метод \Dfe\Stripe\Handler\Charge\Refunded::process()
		 * находил транзакцию типа «capture» путём добавления окончания «-capture»
		 * к идентификатору платежа в Stripe.
		 * Однако если у платежа не было стадии «authorize»,
		 * то в данной точке кода окончание «capture» не добавлялось,
		 * а вот поэтому Refund из интерфейса Stripe не работал.
		 */
		$i->setTransactionId($this->e2i($fc->id($result),
			$needRedirect ? $this->transPrefixForRedirectCase() :
				($capture ? Ev::T_CAPTURE : Ev::T_AUTHORIZE)
		));
		/**
		 * 2016-03-15
		 * Если оставить открытой транзакцию «capture»,
		 * то операция «void» (отмена авторизации платежа) будет недоступна:
		 * https://github.com/magento/magento2/blob/2.1.0/app/code/Magento/Sales/Model/Order/Payment.php#L540-L555
		 * @used-by \Magento\Sales\Model\Order\Payment::canVoid()
		 * Транзакция считается закрытой, если явно не указать «false».
		 *
		 * 2017-01-16
		 * Наоборот: если закрыть транзакцию типа «authorize»,
		 * то операция «Capture Online» из административного интерфейса будет недоступна:
		 * @see \Magento\Sales\Model\Order\Payment::canCapture()
		 *		if ($authTransaction && $authTransaction->getIsClosed()) {
		 *			$orderTransaction = $this->transactionRepository->getByTransactionType(
		 *				Transaction::TYPE_ORDER,
		 *				$this->getId(),
		 *				$this->getOrder()->getId()
		 *			);
		 *			if (!$orderTransaction) {
		 *				return false;
		 *			}
		 *		}
		 * https://github.com/magento/magento2/blob/2.1.3/app/code/Magento/Sales/Model/Order/Payment.php#L263-L281
		 * «How is \Magento\Sales\Model\Order\Payment::canCapture() implemented and used?»
		 * https://mage2.pro/t/650
		 * «How does Magento 2 decide whether to show the «Capture Online» dropdown
		 * on a backend's invoice screen?»: https://mage2.pro/t/2475
		 */
		$i->setIsTransactionClosed($capture && !$needRedirect);
		if ($needRedirect) {
			/**
			 * 2016-07-10
			 * @uses \Magento\Sales\Model\Order\Payment\Transaction::TYPE_PAYMENT —
			 * это единственный транзакция без специального назначения,
			 * и поэтому мы можем безопасно его использовать
			 * для сохранения информации о нашем запросе к платёжной системе.
			 * 2017-01-12
			 * Сделал по аналогии с @see \Df\PaypalClone\Method::addTransaction()
			 * Иначе транзакция не будет записана.
			 * Что интересно, если првоерка 3D Secure не нужна,
			 * то и этой специальной операции записи транзакции не нужно:
			 * она будет записана автоматически.
			 */
			$i->addTransaction(T::TYPE_PAYMENT);
		}
		return $result;
	}, func_get_args());}
1304300
public Charge retrieve(String chargeId) throws BaseException {

		logger.debug("Enter ChargeService::retrieve");
		
		if (StringUtils.isBlank(chargeId)) {
			logger.error("IllegalArgumentException {}", chargeId);
			throw new IllegalArgumentException("chargeId cannot be empty or null");
		}

		// prepare API url
		String apiUrl = requestContext.getBaseUrl() + "charges/{id}".replaceAll("\\{format\\}", "json")
				.replaceAll("\\{" + "id" + "\\}", chargeId.toString());
		logger.info("apiUrl - " + apiUrl);

		// assign TypeReference for deserialization
		TypeReference<Charge> typeReference = new TypeReference<Charge>() {
		};

		// prepare service request
		Request request = new Request.RequestBuilder(MethodType.GET, apiUrl).typeReference(typeReference)
				.context(requestContext).build();

		// make API call
		Response response = sendRequest(request);

		// retrieve response
		Charge chargeResponse = (Charge) response.getResponseObject();

		// set additional attributes
		prepareResponse(request, response, chargeResponse);
		return chargeResponse;
	}
133651
public function getSerie()
    {
        if ($this->_oSerie !== null) {
            return $this->_oSerie;
        }
        $oSerie = oxNew(\OxidEsales\Eshop\Application\Model\VoucherSerie::class);
        if (!$oSerie->load($this->oxvouchers__oxvoucherserieid->value)) {
            throw oxNew(\OxidEsales\Eshop\Core\Exception\ObjectException::class);
        }
        $this->_oSerie = $oSerie;

        return $oSerie;
    }
807062
private static int charge(IAtom atom) {
        Integer charge = atom.getFormalCharge();
        if (charge != null) return charge;
        return 0;
    }
1177298
def start_charge(self):
        """"""
        if not self.__charger_state:
            data = self._controller.command(self._id, 'charge_start',
                                            wake_if_asleep=True)
            if data and data['response']['result']:
                self.__charger_state = True
            self.__manual_update_time = time.time()
1172946
protected function extractCharging()
    {
        $result = [];
        $trailer = $this->registries[2];

        foreach (static::CHARGING_TYPES as $type) {
            $count = "${type}_count";
            $total = "${type}_total";
            $warning = "${type}_warning";

            $result = array_merge(
                $result,
                [
                    $count => (int) $trailer->{$count},
                    $total => (float) ($trailer->{$total} / 100.0),
                    $warning => (int) $trailer->{$warning},
                ]
            );
        }

        return $result;
    }
508424
private Billing generateDefaultBilling() {
        Billing billing = new Billing();
        billing.setPaymentTiming("Postpaid");
        billing.setBillingMethod("ByBandwidth");
        return billing;
    }
628961
public function save()
    {
        parent::save();

        $sOxId = $this->getEditObjectId();
        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editval");

        $oDiscount = oxNew(\OxidEsales\Eshop\Application\Model\Discount::class);
        if ($sOxId != "-1") {
            $oDiscount->load($sOxId);
        } else {
            $aParams['oxdiscount__oxid'] = null;
        }

        // checkbox handling
        if (!isset($aParams['oxdiscount__oxactive'])) {
            $aParams['oxdiscount__oxactive'] = 0;
        }

        //disabling derived items
        if ($oDiscount->isDerived()) {
            return;
        }

        //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
        $oDiscount->setLanguage(0);
        $oDiscount->assign($aParams);
        $oDiscount->setLanguage($this->_iEditLang);
        $oDiscount = \OxidEsales\Eshop\Core\Registry::getUtilsFile()->processFiles($oDiscount);
        try {
            $oDiscount->save();
        } catch (\oxInputException $exception) {
            $newException = oxNew(\OxidEsales\Eshop\Core\Exception\ExceptionToDisplay::class);
            $newException->setMessage($exception->getMessage());
            $this->addTplParam('discount_title', $aParams['oxdiscount__oxtitle']);

            if (false !== strpos($exception->getMessage(), 'DISCOUNT_ERROR_OXSORT')) {
                $messageArgument = \OxidEsales\Eshop\Core\Registry::getLang()->translateString('DISCOUNT_MAIN_SORT', \OxidEsales\Eshop\Core\Registry::getLang()->getTplLanguage(), true);
                $newException->setMessageArgs($messageArgument);
            }

            \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay($newException);

            return;
        }

        // set oxid if inserted
        $this->setEditObjectId($oDiscount->getId());
    }
148914
public function capture(
        $authorizationCode,
        $buyOrder,
        $captureAmount,
        $commerceCode = null
    ) {
        $capture = new CaptureInput();
        $capture->authorizationCode = $authorizationCode;
        $capture->buyOrder = $buyOrder;
        $capture->captureAmount = $captureAmount;
        $capture->commerceId = $commerceCode ? $commerceCode : SecurityHelper::getCommonName(
            $this->service->getCertificationBag()->getClientCertificate()
        );;

        return $this->service->capture($capture);
    }
13884
public function captureEnd()
    {
        $capture = array_pop($this->capture);
        array_unshift($capture['args'], ob_get_clean());
        call_user_func_array(
            [$this, $capture['func']],
            $capture['args']
        );
        return $this;
    }
123057
public function getMonoisotopicMassCharge($charge)
    {
        $massCharge = $this->getMonoisotopicMass();
        $massCharge += PhysicalConstants::PROTON_MASS * $charge;

        return $massCharge / $charge;
    }
710193
public function execute()
    {
        parent::execute();

        $chargeSvc = new HpsDebitService($this->service->servicesConfig());
        return $chargeSvc->charge(
            $this->amount,
            $this->currency,
            $this->trackData,
            $this->pinBlock,
            $this->encryptionData,
            $this->allowDuplicates,
            $this->cashBackAmount,
            $this->allowPartialAuth,
            $this->cardHolder,
            $this->details,
            $this->clientTransactionId
        );
    }
214297
public function capture($amount = null)
    {
        return (new ManagementBuilder(TransactionType::CAPTURE))
            ->withPaymentMethod($this->transactionReference)
            ->withAmount($amount);
    }
488478
public function chargeWithDefaultCustomerCard(RequestModels\BaseCharge
	                                              $requestModel)
	{

		$chargeMapper = new ChargesMapper($requestModel);

		$requestPayload = array (
			'authorization' => $this->_apiSetting->getSecretKey(),
			'mode'          => $this->_apiSetting->getMode(),
			'postedParam'   => $chargeMapper->requestPayloadConverter(),

		);
		$processCharge = \com\checkout\helpers\ApiHttpClient::postRequest($this->_apiUrl->getDefaultCardChargesApiUri(),
			$this->_apiSetting->getSecretKey(),$requestPayload);

		$responseModel = new ResponseModels\Charge($processCharge);


		return $responseModel;
	}
311231
public function createPaymentRequest()
    {
        try {
            $this->currency();
            $this->reference();
            $this->discounts();
            $this->shipping();
            $this->sender();
            $this->urls();
            $this->items();
            $this->config();
            $this->setShoppingCartRecovery();
            return $this->register();
        } catch (\Exception $exception) {
            throw $exception;
        }
    }