payment method created wth package generator
-
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
-
@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.phpconfiguration. As a result, there is no option to upload an icon from the admin panel, andgetImage()returnsnull, 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:clearAfter 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.jsonfile generated by the package generator is unrelated to the payment icon. The icon is controlled entirely by the payment method configuration and thegetImage()method.