/**
  * @param Payment $payment
  *
  * @return void
  *
  * @throws SavePaymentFailedException
  */
 public function markAsPaid(Payment $payment)
 {
     $connection = $this->getConnection();
     $table = $this->getTableName();
     try {
         $connection->update($table, ['paid' => true, 'gateway_id' => $payment->getGatewayId()], ['id' => $payment->id()]);
     } catch (\Exception $exception) {
         throw SavePaymentFailedException::createWithPayment($payment, sprintf('Unable to mark payment #%s as paid', $payment->id()), 0, $exception);
     }
 }
 /**
  * @param Payment  $payment
  * @param Response $purchaseResponse
  *
  * @throws SavePaymentFailedException
  */
 protected function updatePaymentWithStripeCharge(Payment $payment, Response $purchaseResponse)
 {
     $payment->hasBeenPaidWithGatewayTransaction(new StripePaymentId($purchaseResponse->getTransactionReference()));
     try {
         $this->repository->markAsPaid($payment);
     } catch (SavePaymentFailedException $savePaymentFailedException) {
         throw $savePaymentFailedException;
     }
 }
 /**
  * @uses TakePaymentCommandHandler::_handle()
  */
 function it_should_store_a_successful_payment(TakePaymentCommand $command, PaymentRepositoryInterface $repository)
 {
     $this->setRepositoryMethodExpectations($repository);
     /** @noinspection PhpUndefinedMethodInspection */
     $this->handle($command);
     $expectedPayment = new Payment($this->cost, self::TOKEN, self::DESCRIPTION, $this->userEmail);
     $expectedPayment->hasBeenPaidWithGatewayTransaction(new StripePaymentId(self::STRIPE_PAYMENT_ID));
 }