SampleConstants.php File | EasyStore - Documentation | JoomShaper

EasyStore

Updated Last: 24 April 2024

SampleConstants.php File

The SampleConstants class extends the Constants class, inheriting its functionality and adding specific constants and methods for the custom payment gateway.

These constants typically represent configuration settings obtained from the EasyStore settings page.

Namespace and License Information

namespace JoomShaper\Plugin\EasyStore\Sample\Utils;

The namespace specifies the location of the class within the Joomla extension structure.

use JoomShaper\Component\EasyStore\Administrator\Plugin\Constants;

The Constants class is extended, providing a foundation for managing constants related to the payment gateway.

Class Definition

The SampleConstants class extends the Constants class, inheriting its functionality and adding specific constants and methods for the custom payment gateway.

Properties

Here you need to replace the value of the $name variable with the name of your plugin and define the constants needed. 

  • $params: Represents the plugin parameters, allowing access to configuration settings.

  • $name: Specifies the payment plugin name. Replace the value with the actual name of your payment gateway.

  • TEST_URL and LIVE_URL: This is an example. Here we have added Constants defining the URLs for the test and live environments. Update these with your actual gateway URLs or define other constants here depending on your needs.

Methods

Before creating any new constants, have a look at the parent Constant Class to utilize the provided methods to retrieve essential payment gateway information. If it's not already created in the parent class, you need to define it here.

Example method:

public function getTestMerchantKey()
{
    return $this->params->get('test_merchant_key', '');
}

This method retrieves the test merchant key from the plugin parameters.

Constants Class

The Constants class encapsulates constants and configuration settings related to the EasyStore payment plugin. It provides methods for generating URLs, retrieving payment environment details, and obtaining secret keys.

  • Centralizes configuration parameters and constants for the EasyStore payment plugin.
  • Assists in generating URLs for success, cancellation, and webhook actions.
  • Provides methods to retrieve payment environment details and secret keys based on the selected environment.

Methods:

  1. getSuccessUrl: Returns the URL for redirection after successful payment.

  2. getCancelUrl($orderID): Returns the cancellation URL if payment is canceled.

  3. getWebHookUrl: Returns the webhook URL for receiving notifications from the payment portal.

  4. getPaymentEnvironment: Returns the payment environment (test or live).

  5. getTestKey: Returns the test key.

  6. getLiveKey: Returns the live secret key.

  7. getSecretKey: Returns the secret key.