Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    payment method created wth package generator

    Bug Report
    2
    2
    1260
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      telrefaie1980 last edited by

      i have created a payment method with the package generator, which doesn't create a composer.json file, i need to add an icon to my created payment method as it is shown in the checkut page without an icon

      V 1 Reply Last reply Reply Quote 0
      • V
        vaibahv_bagisto @telrefaie1980 last edited by

        @telrefaie1980 The payment method icon displayed on the checkout page is provided by the getImage() method. By default, it retrieves the image from the payment method configuration using:

        $this->getConfigData('image')
        

        The package generator creates a basic payment method, but it does not include an Image/Logo field in the generated system.php configuration. As a result, there is no option to upload an icon from the admin panel, and getImage() returns null, so no icon is displayed.

        Solution

        Add an image field to your payment method configuration in src/Config/system.php:

        [
            'name'          => 'image',
            'title'         => 'admin::app.configuration.index.sales.payment-methods.logo',
            'type'          => 'image',
            'depends'       => 'active:1',
            'channel_based' => true,
            'locale_based'  => false,
            'validation'    => 'mimes:bmp,jpeg,jpg,png,webp',
        ],
        

        Then clear the cache:

        php artisan optimize:clear
        

        After that, go to Admin → Configure → Sales → Payment Methods → Your Payment Method, upload the logo, and save the configuration. The uploaded icon will then be displayed on the checkout page.

        Alternatively, if you want to use a fixed icon instead of an admin-uploaded one, you can override the getImage() method in your payment class:

        public function getImage()
        {
            return $this->getConfigData('image')
                ?: bagisto_asset('images/your-icon.png', 'shop');
        }
        

        Place the icon in your package's published assets so that bagisto_asset() can resolve it correctly.

        Note: The missing composer.json file generated by the package generator is unrelated to the payment icon. The icon is controlled entirely by the payment method configuration and the getImage() method.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post