/** * @param Capture $request * * @throws RequestNotSupportedException if the action dose not support the request. */ public function execute($request) { /** @var Transaction $model */ $model = $request->getModel(); try { $invoice = $this->bitPayClient->createInvoice($model->getRequest()->jsonSerialize()); } catch (\Exception $ex) { throw new RequestNotSupportedException($ex->getMessage()); } $model->setResponse($invoice); }
function it_handles_non_supported_requests(BitpayClient $bitPayClient, Capture $request) { $model = new Transaction(); $model->createRequest(null, null); $bitPayClient->createInvoice($model->getRequest()->jsonSerialize())->willThrow('\\Exception'); $request->getModel()->willReturn($model); $this->shouldThrow('\\Payum\\Core\\Exception\\RequestNotSupportedException')->duringExecute($request); }