src/gateways/Gateway.php
private function _createPaymentResponseFromError(\Exception $exception): PaymentResponse
    {
        if ($exception instanceof CardError) {
            $body = $exception->getJsonBody();
            $data = $body;
            $data['code'] = $body['error']['code'];
            $data['message'] = $body['error']['message'];
            $data['id'] = $body['error']['charge'];
        } else if ($exception instanceof Base) {
            // So it's not a card being declined but something else. ¯\_(ツ)_/¯
            $body = $exception->getJsonBody();
            $data = $body;
            $data['id'] = null;
            $data['message'] = $body['error']['message'] ?? $exception->getMessage();
            $data['code'] = $body['error']['code'] ?? $body['error']['type'] ?? $exception->getStripeCode();
        } else {
            throw $exception;
        }

        return new PaymentResponse($data);
    }
private function _createPaymentResponseFromError(\Exception $exception): PaymentResponse
    {
        if ($exception instanceof CardError) {
            $body = $exception->getJsonBody();
            $data = $body;
            $data['code'] = $body['error']['code'];
            $data['message'] = $body['error']['message'];
            $data['id'] = $body['error']['charge'];
        } else if ($exception instanceof Base) {
            // So it's not a card being declined but something else. ¯\_(ツ)_/¯
            $body = $exception->getJsonBody();
            $data = $body;
            $data['id'] = null;
            $data['message'] = $body['error']['message'] ?? $exception->getMessage();
            $data['code'] = $body['error']['code'] ?? $body['error']['type'] ?? $exception->getStripeCode();
        } else {
            throw $exception;
        }

        return new PaymentResponse($data);
    }
private function _createPaymentResponseFromError ( \ Exception $ exception ) : PaymentResponse { if ( $ exception instanceof CardError ) { $ body = $ exception -> getJsonBody ( ) ; $ data = $ body ; $ data [ 'code' ] = $ body [ 'error' ] [ 'code' ] ; $ data [ 'message' ] = $ body [ 'error' ] [ 'message' ] ; $ data [ 'id' ] = $ body [ 'error' ] [ 'charge' ] ; } else if ( $ exception instanceof Base ) { // So it's not a card being declined but something else. ¯\_(ツ)_/¯ $ body = $ exception -> getJsonBody ( ) ; $ data = $ body ; $ data [ 'id' ] = null ; $ data [ 'message' ] = $ body [ 'error' ] [ 'message' ] ?? $ exception -> getMessage ( ) ; $ data [ 'code' ] = $ body [ 'error' ] [ 'code' ] ?? $ body [ 'error' ] [ 'type' ] ?? $ exception -> getStripeCode ( ) ; } else { throw $ exception ; } return new PaymentResponse ( $ data ) ; }
Create a Response object from an Exception.

@param \Exception $exception

@return PaymentResponse
@throws \Exception if not a Stripe exception
Create a Response object from an Exception .