 module.exports = class JPaymentSubscription extends jraphical.Module
 
   {secure, dash} = require 'bongo'
-  {partition} = require '../../util'
   JUser    = require '../user'
   JPayment = require './index'
 

  cancel: (callback) ->
    @invokeMethod 'cancelSubscription', callback

  terminate: (callback) ->
    @invokeMethod 'terminateSubscription', (err) =>
      return callback err  if err
      refundAmount = @calculateRefund()

      @refund refundAmount, (err) ->
        return callback err  if err
        
        callback null, refundAmount


  resume: (callback) ->

  @checkUserSubscription = secure ({connection:{delegate}}, planCode, callback)->
    throw Error 'reimplement this!'

  isOwnedBy: (account, callback) ->
    account.hasTarget this, 'service subscription', callback

  refund: (options, callback) ->
    payment.createRefund @paymentMethodId, options, callback

  calculateRefund: ->
    { max, ceil } = Math
