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;
    }
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;
    }
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 ; }
Create the appropriate HTTP response for the given payment.

@param Payment $payment the payment that should be processed
@return HTTPResponse
@throws Exception\InvalidConfigurationException
@throws Exception\InvalidStateException
@throws \SilverStripe\Control\HTTPResponse_Exception
Create the appropriate HTTP response for the given payment .