protected function createPaymentResponse($payment)
    {
        if (!$payment) {
            return $this->httpError(
                404,
                _t('SilverStripe\Omnipay\Model\Payment.NotFound', 'Payment could not be found.')
            );
        }

        $intent = $this->getPaymentIntent($payment);
        if (!$intent) {
            return $this->httpError(
                403,
                _t('SilverStripe\Omnipay\Model\Payment.InvalidStatus', 'Invalid/unhandled payment status')
            );
        }

        $service = ServiceFactory::create()->getService($payment, $intent);
        $response = null;
        //do the payment update
        switch ($this->getPaymentActionFromRequest($this->request, $payment)) {
            case "complete":
                $serviceResponse = $service->complete();
                $response = $serviceResponse->redirectOrRespond();
                break;
            case "notify":
                $serviceResponse = $service->complete(array(), true);
                $response = $serviceResponse->redirectOrRespond();
                break;
            case "cancel":
                $serviceResponse = $service->cancel();
                $response = $serviceResponse->redirectOrRespond();
                break;
            default:
                $response = $this->httpError(
                    404,
                    _t('SilverStripe\Omnipay\Model\Payment.InvalidUrl', 'Invalid payment url.')
                );
        }

        return $response;
    }