   cancel: (callback) ->
     @invokeMethod 'cancelSubscription', callback
 
-  terminate: (callback) ->
+  terminate: (oldPlan, callback, applyRefund = yes) ->
     @invokeMethod 'terminateSubscription', (err) =>
       return callback err  if err
-      refundAmount = @calculateRefund()
-
-      @refund refundAmount, (err) ->
-        return callback err  if err
+      amount = @calculateRefund()
+      description =
+        """
+        Credit — #{ oldPlan.title }
+        """
+
+      if applyRefund
+        @refund { amount, description }, (err) ->
+          return callback err  if err
         
-        callback null, refundAmount
+          callback null, amount
+      else
+        callback null, 0
 
 
   resume: (callback) ->

module.exports = class JPaymentSubscription extends jraphical.Module

  {secure, dash} = require 'bongo'
  {partition} = require '../../util'
  JUser    = require '../user'
  JPayment = require './index'


      return callback err  if err
      return callback { message: 'unknown plan code', @planCode }  unless plan

      plan.checkQuota @usage, quantities, multiplyFactor, callback

  createFulfillmentNonce: ({ planCode }, isDebit, callback) ->
    JFulfillmentNonce = require './nonce'
