I can't redirect to Order success page in my custom payment method

I can’t redirect to Order success page in my custom payment method it redirect to cart page.

Magento redirects a customer to his cart when Magento consider the payment as unsuccessful.

yes i create order and redirect success page. this way session is cleared ?

now i confused creating payment method.
How to go next step module?
My flow : get response payment gateway and and create order and redirect to success page.

this is right ? and how to achieve this help me.

Hi

Thanks , successfully create order and customer go to success page Thank You.

                $quote = $this->getCheckout()->getQuote();
                $this->_checkoutSession
                    ->setLastQuoteId($quote->getId())
                    ->setLastSuccessQuoteId($quote->getId())
                    ->clearHelperData();

                $order = $this->_quoteManagement->submit($quote);

                if ($order) {
                    $this->_checkoutSession->setLastOrderId($order->getId())
                                       ->setLastRealOrderId($order->getIncrementId())
                                       ->setLastOrderStatus($order->getStatus());
                }
                $this->messageManager->addSuccess($result['message']);

                $this->_redirect('checkout/onepage/success');

Which file you put this code?