/** * {@inheritDoc} */ public function execute($request) { /** @var $request InitializeOrder */ RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); if ($model['orderRef']) { throw new LogicException('The order has already been initialized.'); } $model->validatedKeysSet(array('price', 'priceArgList', 'vat', 'currency', 'orderId', 'productNumber', 'purchaseOperation', 'view', 'description', 'additionalValues', 'returnUrl', 'cancelUrl', 'clientIPAddress', 'clientIdentifier', 'agreementRef', 'clientLanguage')); $result = $this->api->initialize((array) $model); $model->replace($result); if ($model['redirectUrl']) { throw new HttpRedirect($model['redirectUrl']); } }
/** * @test */ public function shouldUseSoapClientOnInitialize8AndConvertItsResponse() { $response = new \stdClass(); $response->Initialize8Result = '<foo>fooValue</foo>'; $soapClientMock = $this->getMock('SoapClient', array('Initialize8'), array(), '', false); $soapClientMock->expects($this->once())->method('Initialize8')->with($this->isType('array'))->will($this->returnValue($response)); $clientFactoryMock = $this->getMock('Payum\\Payex\\Api\\SoapClientFactory', array('createWsdlClient')); $clientFactoryMock->expects($this->atLeastOnce())->method('createWsdlClient')->will($this->returnValue($soapClientMock)); $orderApi = new OrderApi($clientFactoryMock, array('encryption_key' => 'aKey', 'account_number' => 'aNumber', 'sandbox' => true)); $result = $orderApi->initialize(array()); $this->assertEquals(array('fooValue'), $result); }