                 type                :
                   name              : "type"
                   type              : "hidden"
-                "userVM"            :
-                  itemClass         : KDCustomHTMLView
-                  partial           : "<p>
-                                        You already have a subscription for <strong>personal</strong> VM. You
-                                        <strong>won't be charged</strong>.
-                                      </p>"
-                "userCredits"       :
-                  itemClass         : KDCustomHTMLView
-                  partial           : "<p>
-                                        You have $<span class='price'>0</span> credited to your <strong>personal</strong> account. You <strong>won't
-                                        be charged</strong> until you consume that amount.
-                                      </p>"
-                "groupVM"           :
-                  itemClass         : KDCustomHTMLView
-                  partial           : "<p>
-                                        You already have a subscription for <strong>group</strong> VM. You
-                                        <strong>won't be charged</strong>.
-                                      </p>"
-                "groupCredits"      :
-                  itemClass         : KDCustomHTMLView
-                  partial           : "<p>
-                                        You have $<span class='price'>0</span> credited to your <strong>group</strong> account. You <strong>won't
-                                        be charged</strong> until you consume that amount.
-                                      </p>"
-
 
       if canCreateSharedVM
         modal.modalTabs.forms["Create VM"].buttons.group.show()

      modal.once 'KDModalViewDestroyed', => @dialogIsOpen = no

      form = modal.modalTabs.forms["Create VM"]

      @showPaymentNotices form

      hideLoaders = ->
        {group, user, expensed} = form.buttons

      vmController.on "PaymentModalDestroyed", hideLoaders
      form.on "FormValidationFailed", hideLoaders

  confirmPayment: (type, plan, callback=->)->
    paymentController = KD.getSingleton('paymentController')
    group             = KD.getSingleton("groupsController").getCurrentGroup()

    getBalance = (type, cb)->
      if type is 'user'
        KD.remote.api.JRecurlyPlan.getUserBalance cb
      else
        KD.remote.api.JRecurlyPlan.getGroupBalance group, cb

    buildModal = (content, cb)->
      modal           = new KDModalView
        title         : "Confirm VM Creation"
        content       : "<div class='modalformline'>#{content}</div>"
        overlay       : yes
        buttons       :
          No          :
            title     : "Cancel"
            cssClass  : "modal-clean-gray"
            callback  : =>
              modal.destroy()
              cb()
          Yes         :
            title     : "OK, create the VM"
            cssClass  : "modal-clean-green"
            callback  : =>
              modal.destroy()
              cb()
              paymentController.makePaymentModal type, plan, ->
                console.log "I'm done."
    
    group.canCreateVM
      type     : type
      planCode : plan.code
    , (err, status)->
      if not err and status
        content = """<p>
                       You already subscribed for an additional 
                       <strong>#{type}</strong> VM.
                     </p>
                     <p>
                       You <strong>won't</strong> be charged. Do you want to 
                       continue?.
                     </p>
                  """
        buildModal content, callback
      else
        getBalance type, (err, balance)->
          if not err and balance > 0
            charge = (plan.feeMonthly - balance) / 100
            balance = balance / 100

            content = """<p>
                           You have $#{balance.toFixed(2)} credited to your 
                           <strong>#{type}</strong> account.
                         </p>
                      """

            if charge > 0
              content += """<p>
                              You will be charged for $#{charge.toFixed(2)}. 
                              Do you want to continue?
                            </p>
                         """
            else
              content += """<p>
                              You <strong>won't</strong> be charged. Do you 
                              want to continue?
                            </p>
                         """
          else
            charge = plan.feeMonthly / 100
            content = """<p>
                           You will be charged for $#{charge.toFixed(2)}. Do 
                           you want to continue?
                         </p>
                      """
          buildModal content, callback

  askForApprove:(command, callback)->

