module BtcpayManager
  class CreateInvoice < BtcpayManagerService
    def initialize(amount:, currency:, redirect_url:)
      @amount = amount
      @currency = currency
      @redirect_url = redirect_url
    end

    def call
      post "/invoices", {
        amount: @amount.to_s,
        currency: @currency,
        checkout: {
          redirectURL: @redirect_url,
          redirectAutomatically: true,
          requiresRefundEmail: false
        }
      }
    end
  end
end
