StripeClone/Method.php
final function charge($capture = true) {
		df_sentry_extra($this, 'Amount', $a = dfp_due($this)); /** @var float $a */
		df_sentry_extra($this, 'Need Capture?', df_bts($capture));
		/**
		 * 2017-11-11
		 * Despite of its name, @uses \Magento\Sales\Model\Order\Payment::getAuthorizationTransaction()
		 * simply returns the previous transaction,
		 * and it can be not only an `authorization` transaction,
		 * but a transaction of another type (e.g. `payment`) too.
		 *		public function getAuthorizationTransaction() {
		 *			return $this->transactionManager->getAuthorizationTransaction(
		 *				$this->getParentTransactionId(),
		 *				$this->getId(),
		 *				$this->getOrder()->getId()
		 *			);
		 *		}
		 * The code is the same in Magento 2.0.0 - 2.2.1:
		 * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Sales/Model/Order/Payment.php#L1242-#L1253
		 * https://github.com/magento/magento2/blob/2.2.1/app/code/Magento/Sales/Model/Order/Payment.php#L1316-L1327
		 * @see \Magento\Sales\Model\Order\Payment\Transaction\Manager::getAuthorizationTransaction()
		 *	public function getAuthorizationTransaction($parentTransactionId, $paymentId, $orderId) {
		 *		$transaction = false;
		 *		if ($parentTransactionId) {
		 *			$transaction = $this->transactionRepository->getByTransactionId(
		 *				$parentTransactionId,
		 *				$paymentId,
		 *				$orderId
		 *			);
		 *		}
		 *		return $transaction ?: $this->transactionRepository->getByTransactionType(
		 *			Transaction::TYPE_AUTH,
		 *			$paymentId,
		 *			$orderId
		 *		);
		 *	}
		 * The code is the same in Magento 2.0.0 - 2.2.1:
		 * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Sales/Model/Order/Payment/Transaction/Manager.php#L31-L47
		 * https://github.com/magento/magento2/blob/2.2.1/app/code/Magento/Sales/Model/Order/Payment/Transaction/Manager.php#L31-L47
		 */
		$tPrev = !$capture ? null : $this->ii()->getAuthorizationTransaction(); /** @var T|false|null $tPrev */
		/**
		 * 2017-11-11
		 * The @see \Magento\Sales\Api\Data\TransactionInterface::TYPE_AUTH constant
		 * is absent in Magento < 2.1.0,
		 * but is present as @uses \Magento\Sales\Model\Order\Payment\Transaction::TYPE_AUTH
		 * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Sales/Model/Order/Payment/Transaction.php#L37
		 * https://github.com/magento/magento2/blob/2.0.17/app/code/Magento/Sales/Api/Data/TransactionInterface.php
		 */
		if (!$tPrev || T::TYPE_AUTH !== $tPrev->getTxnType()) {
			$this->chargeNew($capture);
		}
		else {
			/** @var string $txnId */
			df_sentry_extra($this, 'Parent Transaction ID', $txnId = $tPrev->getTxnId());
			df_sentry_extra($this, 'Charge ID', $id = $this->i2e($txnId)); /** @var string $id */
			$this->transInfo($this->fCharge()->capturePreauthorized($id, $this->amountFormat($a)));
			// 2016-12-16
			// Система в этом сценарии по-умолчанию формирует идентификатор транзации как
			// «<идентификатор родительской транзации>-capture».
			// У нас же идентификатор родительской транзации имеет окончание «-authorize»,
			// и оно нам реально нужно (смотрите комментарий к ветке else ниже),
			// поэтому здесь мы окончание «-authorize» вручную подменяем на «-capture».
			$this->ii()->setTransactionId($this->e2i($id, Ev::T_CAPTURE));
		}
	}
final function charge($capture = true) {
		df_sentry_extra($this, 'Amount', $a = dfp_due($this)); /** @var float $a */
		df_sentry_extra($this, 'Need Capture?', df_bts($capture));
		/**
		 * 2017-11-11
		 * Despite of its name, @uses \Magento\Sales\Model\Order\Payment::getAuthorizationTransaction()
		 * simply returns the previous transaction,
		 * and it can be not only an `authorization` transaction,
		 * but a transaction of another type (e.g. `payment`) too.
		 *		public function getAuthorizationTransaction() {
		 *			return $this->transactionManager->getAuthorizationTransaction(
		 *				$this->getParentTransactionId(),
		 *				$this->getId(),
		 *				$this->getOrder()->getId()
		 *			);
		 *		}
		 * The code is the same in Magento 2.0.0 - 2.2.1:
		 * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Sales/Model/Order/Payment.php#L1242-#L1253
		 * https://github.com/magento/magento2/blob/2.2.1/app/code/Magento/Sales/Model/Order/Payment.php#L1316-L1327
		 * @see \Magento\Sales\Model\Order\Payment\Transaction\Manager::getAuthorizationTransaction()
		 *	public function getAuthorizationTransaction($parentTransactionId, $paymentId, $orderId) {
		 *		$transaction = false;
		 *		if ($parentTransactionId) {
		 *			$transaction = $this->transactionRepository->getByTransactionId(
		 *				$parentTransactionId,
		 *				$paymentId,
		 *				$orderId
		 *			);
		 *		}
		 *		return $transaction ?: $this->transactionRepository->getByTransactionType(
		 *			Transaction::TYPE_AUTH,
		 *			$paymentId,
		 *			$orderId
		 *		);
		 *	}
		 * The code is the same in Magento 2.0.0 - 2.2.1:
		 * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Sales/Model/Order/Payment/Transaction/Manager.php#L31-L47
		 * https://github.com/magento/magento2/blob/2.2.1/app/code/Magento/Sales/Model/Order/Payment/Transaction/Manager.php#L31-L47
		 */
		$tPrev = !$capture ? null : $this->ii()->getAuthorizationTransaction(); /** @var T|false|null $tPrev */
		/**
		 * 2017-11-11
		 * The @see \Magento\Sales\Api\Data\TransactionInterface::TYPE_AUTH constant
		 * is absent in Magento < 2.1.0,
		 * but is present as @uses \Magento\Sales\Model\Order\Payment\Transaction::TYPE_AUTH
		 * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Sales/Model/Order/Payment/Transaction.php#L37
		 * https://github.com/magento/magento2/blob/2.0.17/app/code/Magento/Sales/Api/Data/TransactionInterface.php
		 */
		if (!$tPrev || T::TYPE_AUTH !== $tPrev->getTxnType()) {
			$this->chargeNew($capture);
		}
		else {
			/** @var string $txnId */
			df_sentry_extra($this, 'Parent Transaction ID', $txnId = $tPrev->getTxnId());
			df_sentry_extra($this, 'Charge ID', $id = $this->i2e($txnId)); /** @var string $id */
			$this->transInfo($this->fCharge()->capturePreauthorized($id, $this->amountFormat($a)));
			// 2016-12-16
			// Система в этом сценарии по-умолчанию формирует идентификатор транзации как
			// «<идентификатор родительской транзации>-capture».
			// У нас же идентификатор родительской транзации имеет окончание «-authorize»,
			// и оно нам реально нужно (смотрите комментарий к ветке else ниже),
			// поэтому здесь мы окончание «-authorize» вручную подменяем на «-capture».
			$this->ii()->setTransactionId($this->e2i($id, Ev::T_CAPTURE));
		}
	}
final function charge ( $ capture = true ) { df_sentry_extra ( $ this , 'Amount' , $ a = dfp_due ( $ this ) ) ; /** @var float $a */ df_sentry_extra ( $ this , 'Need Capture?' , df_bts ( $ capture ) ) ; /**
		 * 2017-11-11
		 * Despite of its name, @uses \Magento\Sales\Model\Order\Payment::getAuthorizationTransaction()
		 * simply returns the previous transaction,
		 * and it can be not only an `authorization` transaction,
		 * but a transaction of another type (e.g. `payment`) too.
		 *		public function getAuthorizationTransaction() {
		 *			return $this->transactionManager->getAuthorizationTransaction(
		 *				$this->getParentTransactionId(),
		 *				$this->getId(),
		 *				$this->getOrder()->getId()
		 *			);
		 *		}
		 * The code is the same in Magento 2.0.0 - 2.2.1:
		 * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Sales/Model/Order/Payment.php#L1242-#L1253
		 * https://github.com/magento/magento2/blob/2.2.1/app/code/Magento/Sales/Model/Order/Payment.php#L1316-L1327
		 * @see \Magento\Sales\Model\Order\Payment\Transaction\Manager::getAuthorizationTransaction()
		 *	public function getAuthorizationTransaction($parentTransactionId, $paymentId, $orderId) {
		 *		$transaction = false;
		 *		if ($parentTransactionId) {
		 *			$transaction = $this->transactionRepository->getByTransactionId(
		 *				$parentTransactionId,
		 *				$paymentId,
		 *				$orderId
		 *			);
		 *		}
		 *		return $transaction ?: $this->transactionRepository->getByTransactionType(
		 *			Transaction::TYPE_AUTH,
		 *			$paymentId,
		 *			$orderId
		 *		);
		 *	}
		 * The code is the same in Magento 2.0.0 - 2.2.1:
		 * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Sales/Model/Order/Payment/Transaction/Manager.php#L31-L47
		 * https://github.com/magento/magento2/blob/2.2.1/app/code/Magento/Sales/Model/Order/Payment/Transaction/Manager.php#L31-L47
		 */ $ tPrev = ! $ capture ? null : $ this -> ii ( ) -> getAuthorizationTransaction ( ) ; /** @var T|false|null $tPrev */ /**
		 * 2017-11-11
		 * The @see \Magento\Sales\Api\Data\TransactionInterface::TYPE_AUTH constant
		 * is absent in Magento < 2.1.0,
		 * but is present as @uses \Magento\Sales\Model\Order\Payment\Transaction::TYPE_AUTH
		 * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Sales/Model/Order/Payment/Transaction.php#L37
		 * https://github.com/magento/magento2/blob/2.0.17/app/code/Magento/Sales/Api/Data/TransactionInterface.php
		 */ if ( ! $ tPrev || T :: TYPE_AUTH !== $ tPrev -> getTxnType ( ) ) { $ this -> chargeNew ( $ capture ) ; } else { /** @var string $txnId */ df_sentry_extra ( $ this , 'Parent Transaction ID' , $ txnId = $ tPrev -> getTxnId ( ) ) ; df_sentry_extra ( $ this , 'Charge ID' , $ id = $ this -> i2e ( $ txnId ) ) ; /** @var string $id */ $ this -> transInfo ( $ this -> fCharge ( ) -> capturePreauthorized ( $ id , $ this -> amountFormat ( $ a ) ) ) ; // 2016-12-16 // Система в этом сценарии по-умолчанию формирует идентификатор транзации как // «<идентификатор родительской транзации>-capture». // У нас же идентификатор родительской транзации имеет окончание «-authorize», // и оно нам реально нужно (смотрите комментарий к ветке else ниже), // поэтому здесь мы окончание «-authorize» вручную подменяем на «-capture». $ this -> ii ( ) -> setTransactionId ( $ this -> e2i ( $ id , Ev :: T_CAPTURE ) ) ; } }
2016-03-07
@override
@see https://stripe.com/docs/charges
@see \Df\Payment\Method::charge()
@used-by \Df\Payment\Method::authorize()
@used-by \Df\Payment\Method::capture()
@used-by \Dfe\Omise\Init\Action::redirectUrl()
@param bool|null $capture [optional]
@throws \Stripe\Error\Card
2016 - 03 - 07