Exemple #1
0
 /**
  * @param Payment                     $payment
  * @param RecurringPaymentInformation $paymentInformation
  *
  * @dataProvider dataProvider
  */
 public function testXMLGeneration($payment, $paymentInformation)
 {
     $prophet = new Prophet();
     $orderService = $prophet->prophesize('Checkdomain\\TeleCash\\IPG\\API\\Service\\OrderService');
     $recurring = new Install($orderService->reveal(), $payment, $paymentInformation);
     $document = $recurring->getDocument();
     $document->appendChild($recurring->getElement());
     $elementRecurringPayment = $document->getElementsByTagName('ns2:RecurringPayment');
     $this->assertEquals(1, $elementRecurringPayment->length, 'Expected element RecurringPayment not found');
     $children = [];
     /** @var \DOMNode $child */
     foreach ($elementRecurringPayment->item(0)->childNodes as $child) {
         $children[$child->nodeName] = $child->nodeValue;
     }
     $this->assertArrayHasKey('ns2:RecurringPaymentInformation', $children, 'Expected element RecurringPaymentInformation not found');
     //no need to further test RecurringPaymentInformation, as this is already covered in RecurringPaymentInformationTest
     $this->assertArrayHasKey('ns1:Payment', $children, 'Expected element Payment not found');
     //no need to further test Payment, as this is already covered in PaymentTest
     $this->assertArrayHasKey('ns2:Function', $children, 'Expected element Function not found');
     $this->assertEquals('install', $children['ns2:Function'], 'Function did not match');
     $this->assertArrayNotHasKey('ns2:OrderId', $children, 'Unexpected element OrderId was found');
 }
Exemple #2
0
 /**
  * Install a recurring payment.
  *
  * @param string    $hostedDataId
  * @param float     $amount
  * @param \DateTime $startDate
  * @param int       $count
  * @param int       $frequency
  * @param string    $period
  *
  * @return Response\Order\Sell|Response\Error
  * @throws \Exception
  */
 public function installRecurringPayment($hostedDataId, $amount, \DateTime $startDate, $count, $frequency, $period)
 {
     $service = $this->getService();
     $paymentInformation = new Model\RecurringPaymentInformation($startDate, $count, $frequency, $period);
     $payment = new Model\Payment($hostedDataId, $amount);
     $recurringPaymentAction = new Request\Action\RecurringPayment\Install($service, $payment, $paymentInformation);
     return $recurringPaymentAction->install();
 }