Search code examples
opencartopencart-moduleopencart-3

opencart custom payment extension is not showing in the payment method


I am writing a custom payment extension in opencart 3. I have setup necessary method and the plugin is not enabling. I am trying to enable the plugin automatically after installation it does work yet. These are my code. directory> upload/admin/controller/extension/mycustom.php

private $info_status = true;

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
        $this->model_setting_setting->editSetting('gtpayment', $this->request->post);
        $this->session->data['success'] = $this->language->get('text_success');
        $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true));
    }
if (isset($this->request->post['gtpayment_status'])) {          
        $data['gtpayment_status'] = $this->request->post['gtpayment_status'];   
    }else{  
        $data['gtpayment_status'] = $this->config->get('gtpayment_status');
    }

If these code is not correct is there a possible way to make a plugin automatically enable after installation.


Solution

  • 1 - You missed payment folder under extension folder.

    2 - If your actual module is gtpayment, your module filename and your classname must be gtpayment:

    admin/controller/extension/payment/gtpayment.php
    

    And

    class ControllerExtensionPaymentGtpayment extends Controller {
    

    3 - You must use $data['payment_gtpayment_status'] instead $data['gtpayment_status']

    Extensions are now prefixed by their category. so paypal_status would become payment_papal_status

    Source of quote