import axios from "axios";

const START_AFRICA_BASE_URL = process.env.START_AFRICA_BASE_URL;
const START_AFRICA_API_KEY = process.env.START_AFRICA_API_KEY;

class StartAfricaService {
  /**
   * Initiate localized transfer / payout via StartAfrica
   */
  static async initiateTransfer(payload) {
    try {
      const response = await axios.post(`${START_AFRICA_BASE_URL}/transaction/transfer`, payload, {
        headers: {
          Authorization: `Bearer ${START_AFRICA_API_KEY}`,
          "Content-Type": "application/json",
        },
      });
      return response.data;
    } catch (error) {
      console.error("❌ StartAfrica transfer error:", error.response?.data || error.message);
      throw error;
    }
  }
}

export default StartAfricaService;
