Ejemplo n.º 1
0
 /**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage There was an error capturing the transaction: error.
  */
 public function testCaptureError()
 {
     $amount = self::AUTH_AMOUNT;
     $paymentId = 1005;
     $paymentObject = $this->setupPaymentObjectForCapture($paymentId);
     //setup braintree error response
     $resultError = $this->getMockBuilder('\\Braintree_Result_Error')->disableOriginalConstructor()->getMock();
     $this->errorHelperMock->expects($this->once())->method('parseBraintreeError')->with($resultError)->willReturn(new \Magento\Framework\Phrase('error'));
     $this->braintreeTransactionMock->expects($this->once())->method('submitForSettlement')->with(self::AUTH_TRAN_ID, $amount)->willReturn($resultError);
     $this->psrLoggerMock->expects($this->once())->method('critical');
     $this->model->capture($paymentObject, $amount);
 }
Ejemplo n.º 2
0
 /**
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Some transactions are already settled or voided and cannot be voided.
  */
 public function testVoidInvalidState()
 {
     $orderId = 1005;
     $paymentObject = $this->setupPaymentObjectForVoid($orderId);
     $transactions = ['1' => \Braintree_Transaction::factory(['id' => '1', 'status' => \Braintree_Transaction::SETTLED])];
     $this->setupTransactionIds($orderId, array_keys($transactions));
     $index = 0;
     foreach ($transactions as $id => $transaction) {
         $this->braintreeTransactionMock->expects($this->at($index))->method('find')->with($id)->willReturn($transaction);
         $index++;
     }
     $this->model->void($paymentObject);
 }
Ejemplo n.º 3
0
 /**
  * Clones existing transaction
  *
  * @param float $amount
  * @param string $transactionId
  * @return mixed
  * @throws \Exception
  */
 protected function cloneTransaction($amount, $transactionId)
 {
     $this->_debug(['clone-' . $transactionId . ' amount=' . $amount]);
     $result = $this->braintreeTransaction->cloneTransaction($transactionId, ['amount' => $amount, 'options' => ['submitForSettlement' => true]]);
     $this->_debug($this->_convertObjToArray($result));
     return $result;
 }