/** * Send capture request to gateway * * @param \Magento\Framework\DataObject|\Magento\Payment\Model\InfoInterface $payment * @param float $amount * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount) { if ($amount <= 0) { throw new \Magento\Framework\Exception\LocalizedException(__('Invalid amount for capture.')); } $payment->setAmount($amount); if ($payment->getParentTransactionId()) { $payment->setAnetTransType(self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE); $payment->setXTransId($this->getRealParentTransactionId($payment)); } else { $payment->setAnetTransType(self::REQUEST_TYPE_AUTH_CAPTURE); } $result = $this->getResponse(); if (empty($result->getData())) { $request = $this->buildRequest($payment); $result = $this->postRequest($request); } return $this->processCapture($result, $payment); }