defmodule PaymentGatewayApp do @moduledoc """ PaymentGatewayApp is an independent OTP application for payment processing. This module provides the public API for payment operations that can be called by the main CloudLayer application. ## Configuration The Payment Gateway can be configured in your `config.exs`: config :payment_gateway_app, api_provider: PaymentGatewayApp.Providers.MockProvider, api_key: System.get_env("PG_API_KEY"), api_secret: System.get_env("PG_API_SECRET"), api_endpoint: "https://api.payment-provider.com" ## Usage # Start a payment {:ok, payment} = PaymentGatewayApp.start_payment(100.00, "USD", "user123") # Check payment status {:ok, status} = PaymentGatewayApp.get_payment_status(payment.id) """ alias PaymentGatewayApp.PaymentInitiator alias PaymentGatewayApp.StatusChecker @doc """ Initiates a new payment transaction. ## Parameters - `amount` - Payment amount as a float or integer - `currency` - Currency code (e.g., "USD", "EUR") - `user_id` - Unique identifier for the user making the payment - `opts` - Additional options (optional) ## Returns - `{:ok, payment_data}` - Success with payment details - `{:error, reason}` - Failure with error reason ## Examples iex> PaymentGatewayApp.start_payment(50.00, "USD", "user_123") {:ok, %{id: "pay_123", status: "pending", ...}} """ def start_payment(amount, currency, user_id, opts \\ []) do PaymentInitiator.initiate_payment(amount, currency, user_id, opts) end @doc """ Retrieves the current status of a payment. ## Parameters - `payment_id` - Unique payment transaction identifier ## Returns - `{:ok, status_data}` - Success with current status - `{:error, reason}` - Failure with error reason ## Examples iex> PaymentGatewayApp.get_payment_status("pay_123") {:ok, %{status: "completed", ...}} """ def get_payment_status(payment_id) do StatusChecker.check_status(payment_id) end end