       else if vmInfo.type is 'expensed'          then 'expensed'
       else 'group'
 
-    @fetchSubscription getGroup(), type, vmInfo.planCode,\
-      @createDeleteConfirmationModal.bind this, type, callback
+    @fetchSubscription getGroup(), type, vmInfo.planCode, (err, subscription) =>
+      console.error err  if err
+      @createDeleteConfirmationModal type, callback, subscription
 
   # views
+
+  fetchPlanByCode: (planCode, callback) ->
+
+    { JPaymentPlan } = KD.remote.api
+
+    JPaymentPlan.fetchPlanByCode planCode, callback
 
   fetchPaymentInfo: (type, callback) ->
 
     { JPaymentPlan } = KD.remote.api
+
+    debugger
 
     switch type
       when 'group', 'expensed'

      @emit 'PaymentDataChanged'

  fetchSubscription: do ->
    findActiveSubscription = (subs, planCode, callback) ->
      subs.reverse().forEach (sub) ->
        if sub.planCode is planCode and sub.status in ['canceled', 'active']
          return callback sub

      callback 'none'

    fetchSubscription = (type, planCode, callback) ->
      { JPaymentSubscription } = KD.remote.api

        getGroup().checkPayment (err, subs) =>
          findActiveSubscription subs, planCode, callback
      else
        JPaymentSubscription.fetchUserSubscriptions (err, subs) ->
          findActiveSubscription subs, planCode, callback

  confirmPayment: ->
    console.error 'confirm payment is removed'

  makePayment: (paymentMethodId, plan, amount) ->
    vmController = KD.getSingleton('vmController')

    if 'string' is typeof plan
      @fetchPlanByCode plan, (err, planObj) =>
        return console.error err  if err
        @makePayment paymentMethodId, planObj, amount

    else if amount is 0
      vmController.createGroupVM type, plan.code

    # else if type in ['group', 'expensed']
    #   paymentMethod = { plan: plan.code, multiple: yes }
    #   getGroup().makePayment paymentMethod, (err, result)->
    #     return KD.showError err  if err
    #     vmController.createGroupVM type, plan.code

    else
      plan.subscribe paymentMethodId, multiple: yes, (err, result)->
        return KD.showError err  if err
        vmController.createGroupVM type, plan.code

