public function testUnsAdditionalInformation()
 {
     // set array to additional
     $data = ['key1' => 'data1', 'key2' => 'data2'];
     $this->info->setAdditionalInformation($data);
     // unset by key
     $this->assertEquals(['key2' => 'data2'], $this->info->unsAdditionalInformation('key1')->getAdditionalInformation());
     // unset all
     $this->assertEmpty($this->info->unsAdditionalInformation()->getAdditionalInformation());
 }
Beispiel #2
0
 /**
  * Capture payment
  *
  * @param InfoInterface|Payment|Object $payment
  * @param float $amount
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  * @throws \Magento\Framework\Exception\State\InvalidTransitionException
  */
 public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount)
 {
     if ($payment->getAdditionalInformation(self::PNREF)) {
         $request = $this->buildBasicRequest();
         $request->setAmt(round($amount, 2));
         $request->setTrxtype(self::TRXTYPE_SALE);
         $request->setOrigid($payment->getAdditionalInformation(self::PNREF));
         $payment->unsAdditionalInformation(self::PNREF);
     } elseif ($payment->getParentTransactionId()) {
         $request = $this->buildBasicRequest();
         $request->setOrigid($payment->getParentTransactionId());
         $captureAmount = $this->_getCaptureAmount($amount);
         if ($captureAmount) {
             $request->setAmt($captureAmount);
         }
         $trxType = $this->getInfoInstance()->hasAmountPaid() ? self::TRXTYPE_SALE : self::TRXTYPE_DELAYED_CAPTURE;
         $request->setTrxtype($trxType);
     } else {
         $request = $this->_buildPlaceRequest($payment, $amount);
         $request->setTrxtype(self::TRXTYPE_SALE);
     }
     $this->addRequestOrderInfo($request, $payment->getOrder());
     $response = $this->postRequest($request, $this->getConfig());
     $this->processErrors($response);
     $this->setTransStatus($payment, $response);
     return $this;
 }