import { API_ROOT } from 'config'
import { callApi } from 'helpers'

import type { SubscriptionResponse } from '../getSubscriptions'

type Args = {
  item?: SubscriptionResponse,
  paymentIntentId: string,
}

export const notifySuccessfulSubscription = ({ item, paymentIntentId }: Args) => {
  const config = {
    body: {
      item,
      pi_id: paymentIntentId,
    },
  }

  return callApi({
    config,
    url: `${API_ROOT}/account/pay-finish`,
  })
}
