/**
  * @param Payment            $payment
  * @param TransactionDetails $transactionDetails
  *
  * @dataProvider dataProvider
  */
 public function testXMLGeneration($payment, $transactionDetails)
 {
     $prophet = new Prophet();
     $orderService = $prophet->prophesize('Checkdomain\\TeleCash\\IPG\\API\\Service\\OrderService');
     $sellHosted = new SellHostedData($orderService->reveal(), $payment, $transactionDetails);
     $document = $sellHosted->getDocument();
     $document->appendChild($sellHosted->getElement());
     $elementCCType = $document->getElementsByTagName('ns1:CreditCardTxType');
     $this->assertEquals(1, $elementCCType->length, 'Expected element CreditCardTxType not found');
     $children = [];
     /** @var \DOMNode $child */
     foreach ($elementCCType->item(0)->childNodes as $child) {
         $children[$child->nodeName] = $child->nodeValue;
     }
     $this->assertArrayHasKey('ns1:Type', $children, 'Expected element Type not found');
     $this->assertEquals('sale', $children['ns1:Type'], 'Type did not match');
     $elementPayment = $document->getElementsByTagName('ns1:Payment');
     $this->assertEquals(1, $elementPayment->length, 'Expected element Payment not found');
     if ($transactionDetails !== null) {
         $elementDetails = $document->getElementsByTagName('ns2:TransactionDetails');
         $this->assertEquals(1, $elementDetails->length, 'Expected element TransactionDetails not found');
     } else {
         $elementDetails = $document->getElementsByTagName('ns2:TransactionDetails');
         $this->assertEquals(0, $elementDetails->length, 'Unexpected element TransactionDetails was found');
     }
 }
Beispiel #2
0
 /**
  * Make a sale using a previously stored credit card information
  *
  * @param string      $hostedDataId
  * @param float       $amount
  * @param string|null $comments
  * @param string|null $invoiceNumber
  *
  * @return Response\Order\Sell|Response\Error
  * @throws \Exception
  */
 public function sellUsingHostedData($hostedDataId, $amount, $comments = null, $invoiceNumber = null)
 {
     $service = $this->getService();
     $payment = new Model\Payment($hostedDataId, $amount);
     if (!empty($comments) || !empty($invoiceNumber)) {
         $transactionDetails = new Model\TransactionDetails('ns1', $comments, $invoiceNumber);
     } else {
         $transactionDetails = null;
     }
     $sellAction = new Request\Transaction\SellHostedData($service, $payment, $transactionDetails);
     return $sellAction->sell();
 }