generateEndpoint method

String generateEndpoint(
  1. PaymentEnvironment paymentEnvironment
)

Determines the appropriate API base URL based on the payment environment.

This method ensures requests are sent to the correct environment:

  • Sandbox: Uses test endpoints that don't process real money
  • Production: Uses live endpoints for real transactions

Parameters:

  • paymentEnvironment: The environment to use (sandbox/production)

Returns:

  • The base URL for the specified environment

The URLs are defined in the configuration and should not be modified unless instructed by the CoFee Payment team.

Implementation

String generateEndpoint(PaymentEnvironment paymentEnvironment) {
  switch (paymentEnvironment) {
    case PaymentEnvironment.sandbox:
      return SANDBOX_API_BASE_URL;
    case PaymentEnvironment.production:
      return API_BASE_URL;
  }
}