Enum Class MpesaEnvironment

java.lang.Object
java.lang.Enum<MpesaEnvironment>
io.github.openpaydev.mpesa.core.MpesaEnvironment
All Implemented Interfaces:
Serializable, Comparable<MpesaEnvironment>, Constable

public enum MpesaEnvironment extends Enum<MpesaEnvironment>
Enum representing the M-Pesa API environments and their corresponding endpoint URLs.

This enum centralizes all API endpoint URLs, ensuring that the client code does not need to be aware of the specific paths for authentication or transactions.

  • Enum Constant Details

    • SANDBOX

      public static final MpesaEnvironment SANDBOX
      The Sandbox environment for development and testing purposes.
    • PRODUCTION

      public static final MpesaEnvironment PRODUCTION
      The Production environment for live, real-money transactions.
  • Method Details

    • values

      public static MpesaEnvironment[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static MpesaEnvironment valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getAuthUrl

      public String getAuthUrl()
      Returns the full URL for the OAuth token generation endpoint.
      Returns:
      The complete authentication URL as a String.
    • getStkPushUrl

      public String getStkPushUrl()
      Returns the full URL for the STK Push (Lipa Na M-Pesa Online) process request endpoint.
      Returns:
      The complete STK Push URL as a String.
    • getStkQueryUrl

      public String getStkQueryUrl()
      Returns the full URL for the STK Push Query (Transaction Status) endpoint.
      Returns:
      The complete STK Push Query URL as a String.
    • getC2bRegisterUrl

      public String getC2bRegisterUrl()
      Returns the full URL for the C2B Register URL endpoint.
      Returns:
      The complete C2B Register URL as a String.