import { get, post } from '../utils/http.js'

// 获取支付应用信息
export const getPayAplication = async (applicationId) => {
  try {
    const response = await get(`/order/web/pay/application/${applicationId}`)
    return response
  } catch (error) {
    console.error('Failed to fetch get pay application:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取商品列表
export const getAppCommodityCard = async (params) => {
  try {
    const response = await get(
      `/order/web/pay/commodity?applicationId=${params.applicationId}&payCountryId=${params.payCountryId}&regionId=${params.regionId}&type=${params.type}`
    )
    return response
  } catch (error) {
    console.error('Failed to fetch get app commodity card:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 下单充值
export const payPlaceAnOrderRecharge = async (data) => {
  try {
    const response = await post('/order/web/pay/recharge', data)
    return response
  } catch (error) {
    console.error('Failed to fetch get pay application:', error)
    throw error
  }
}
