Skip to content

Understanding Payment Configuration

Now that you've created your payment method, let's understand how the configuration files work and what each property does.

Payment Method Configuration

In the previous section, we created config/payment-methods.php. Let's understand each property:

php
<?php

return [
    'custom_stripe_payment' => [
        'code'        => 'custom_stripe_payment',
        'title'       => 'Credit Card (Stripe)',
        'description' => 'Secure credit card payments powered by Stripe',
        'class'       => 'Webkul\CustomStripePayment\Payment\CustomStripePayment',
        'active'      => true,
        'sort'        => 1,
    ],
];

Configuration Properties Explained

PropertyTypePurposeDescription
codeStringUnique identifierMust match the array key and be used consistently across your payment method
titleStringDefault display nameShown to customers during checkout (can be overridden in admin)
descriptionStringPayment method descriptionBrief explanation of the payment method
classStringPayment class namespaceFull path to your payment processing class
activeBooleanDefault statusWhether the payment method is enabled by default
sortIntegerDisplay orderLower numbers appear first in checkout (0 = first)

Configuration Key Consistency

The array key (custom_stripe_payment) must match the code property and be used consistently in:

  • Your payment class $code property
  • System configuration key path
  • Route names and identifiers

System Configuration (Admin Settings)

We also created system.php for the admin interface. Let's understand what we built:

php
<?php

return [
    [
        'key'    => 'sales.payment_methods.custom_stripe_payment',
        'name'   => 'Custom Stripe Payment',
        'info'   => 'Custom Stripe Payment Method Configuration',
        'sort'   => 1,
        'fields' => [
            [
                'name'          => 'active',
                'title'         => 'Status',
                'type'          => 'boolean',
                'default_value' => true,
                'channel_based' => true,
            ],
            [
                'name'          => 'title',
                'title'         => 'Title',
                'type'          => 'text',
                'default_value' => 'Credit Card (Stripe)',
                'channel_based' => true,
                'locale_based'  => true,
            ],
            [
                'name'          => 'description',
                'title'         => 'Description',
                'type'          => 'textarea',
                'default_value' => 'Secure credit card payments',
                'channel_based' => true,
                'locale_based'  => true,
            ],
            [
                'name'          => 'sort',
                'title'         => 'Sort Order',
                'type'          => 'text',
                'default_value' => '1',
            ],
        ],
    ],
];

System Configuration Properties Explained

The system configuration creates the admin interface that allows store administrators to manage payment method settings. Each property serves a specific purpose in creating a user-friendly admin experience.

Section Properties

These properties define the overall section that appears in the admin configuration panel:

PropertyPurposeDescription
keyConfiguration pathsales.payment_methods.{your_code} - where settings are stored
nameAdmin section titleDisplayed in the admin configuration panel
infoSection descriptionAdditional information shown to administrators
sortSection orderOrder in which payment methods appear in admin

Field Properties

These properties define each individual form field that administrators can configure:

PropertyPurposeDescription
nameField identifierUsed to store and retrieve configuration values
titleField labelLabel displayed in the admin form
typeInput typetext, textarea, boolean, select, password, etc.
default_valueDefault settingInitial value when first configured
channel_basedMulti-store supportDifferent values per sales channel
locale_basedMulti-language supportTranslatable content per language
validationField validationRules like required, numeric, email

How Configuration is Used

When you call $this->getConfigData('title') in your payment class, Bagisto looks up:

core()->getConfigData('sales.payment_methods.custom_stripe_payment.title')

This retrieves the value from the admin configuration that administrators can modify.

System Configuration Reference

For detailed information about creating admin interface forms for your payment method, see:

📖 Package Development - System Configuration → Complete guide to creating admin configuration interfaces with all field types and options.

What's Next?

Now that you understand payment configuration, let's explore the payment class:

📖 Understanding Payment Class → Learn how to implement payment processing logic and handle transactions.

📖 Back to Getting Started ← Review the complete payment method development workflow.

Released under the MIT License.