/** * {@inheritDoc} * * @param Sync $request */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); if ($model['location']) { $this->gateway->execute($fetchOrder = new FetchOrder($model)); $model->replace($fetchOrder->getOrder()->marshal()); } }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request \Payum\Core\Request\Sync */ if (false == $this->supports($request)) { throw RequestNotSupportedException::createActionNotSupported($this, $request); } $model = ArrayObject::ensureArrayObject($request->getModel()); if ($model['location']) { $this->payment->execute($fetchOrder = new FetchOrder($model)); $model->replace($fetchOrder->getOrder()->marshal()); } }
/** * @test */ public function shouldRecoverAfterTimeout() { $model = array('location' => 'theLocation', 'cart' => array('items' => array(array('foo'), array('bar')))); $expectedOrder = null; $connector = $this->createConnectorMock(); $connector->expects($this->at(0))->method('apply')->with('GET')->will($this->throwException(new \Klarna_Checkout_ConnectionErrorException())); $connector->expects($this->at(1))->method('apply')->with('GET')->will($this->returnCallback(function ($method, $order, $options) use(&$expectedOrder) { $expectedOrder = $order; })); $action = new FetchOrderAction($connector); $action->setApi(new Config()); $action->execute($request = new FetchOrder($model)); $this->assertSame($expectedOrder, $request->getOrder()); }