/** * {@inheritDoc} */ public function createCaptureToken($paymentName, $model, $afterPath, array $afterParameters = array()) { $afterToken = $this->createToken($paymentName, $model, $afterPath, $afterParameters); $captureToken = $this->createToken($paymentName, $model, $this->capturePath); $captureToken->setAfterUrl($afterToken->getTargetUrl()); $this->tokenStorage->updateModel($captureToken); return $captureToken; }
/** * @param Notify $request * * @throws RequestNotSupportedException if the action dose not support the request. */ public function execute($request) { /** @var Array $notification */ $notification = $request->getNotification(); $response = BitPayNotification::fromArray($notification); /** @var Transaction $model */ $model = $this->storageInterface->findModelById($response->getId()); $model->setResponse($response); $this->storageInterface->updateModel($model); }
protected function onPostXXX($request) { $this->stackLevel--; if ($request instanceof ModelAggregateInterface) { $this->scheduleForUpdateIfSupported($request->getModel()); } if (0 === $this->stackLevel) { foreach ($this->scheduledForUpdateModels as $modelHash => $model) { $this->storage->updateModel($model); unset($this->scheduledForUpdateModels[$modelHash]); } } }
function it_should_store_invoices(StorageInterface $storageInterface, SecuredNotify $request, Transaction $transaction) { $notification = ['id' => '1', 'url' => 'http://bitpay.com/invoice', 'status' => BitPayNotification::STATUS_CONFIRMED, 'btcPrice' => 0.001, 'price' => 0.001, 'currency' => 'BTC', 'invoiceTime' => '20140101T19:01:01.123Z', 'expirationTime' => '20140101T19:01:01.123Z', 'currentTime' => '20140101T19:01:01.123Z']; $invoice = BitPayNotification::fromArray($notification); $request->getNotification()->willReturn($notification); $transaction->setResponse($invoice)->shouldBeCalled(); $storageInterface->findModelById('1')->willReturn($transaction); $storageInterface->updateModel($transaction)->shouldBeCalled(); $this->execute($request); }