One Time Invoice right before deleting a customer

Michael van Rooijen's Avatar

Michael van Rooijen

28 Aug, 2011 09:25 PM

Hi,

Quick question. Say you have set up "tracked items" with an overage of "0" so you can use it as "metered billing", and let's say a user has consumed 50 overages, but the billing cycle hasn't ended yet and the user decides to cancel his/her account. That would mean that the user doesn't get charged for the 50 overages. I assume a way to still charge the customer is by creating a one-time (instant) invoice.

Currently I've set it up in a way so that before the user deletes his/her account, I do an API call to CG to get the current amount of overages and then manually calculate that against the price per overage. With that I generate a one-time invoice via another API call. Then immediately after CG responds to that, I invoke one final API call to delete the customer from the CG database.

Will the customer still be charged (has has he/she been?) even though the customer was sent a "one-time invoice" right before being deleted from the CG database? I was trying to test this with PayPal but unfortunately it's not possible to charge your own account so I couldn't see if this would work or whether the transaction would be canceled.

Thanks,
Michael

  1. Support Staff 1 Posted by Marc Guyer on 29 Aug, 2011 04:00 PM

    Marc Guyer's Avatar

    Hi Michael --

    Currently I've set it up in a way so that before the user deletes his/her account, I do an API call to CG to get the current amount of overages and then manually calculate that against the price per overage. With that I generate a one-time invoice via another API call. Then immediately after CG responds to that, I invoke one final API call to delete the customer from the CG database.

    You could use the technique you describe but I don't recommend it. Deleting customers is really only intended to be used for development/testing purposes or when a customer was created in error. If you delete a customer, all data is lost and you will have no record of past revenue. Alternatively, simply cancel the customer's account.

    Will the customer still be charged (has has he/she been?) even though the customer was sent a "one-time invoice" right before being deleted from the CG database? I was trying to test this with PayPal but unfortunately it's not possible to charge your own account so I couldn't see if this would work or whether the transaction would be canceled.

    I wouldn't be able to answer that question definitively without some testing of your particular setup. When deleting, all data is removed including data at the gateway (PayPal in this case), when possible so there could be an issue there.

    What I recommend is to not use a one-time invoice at all. Since you're wanting to charge the customer for the current state of their account, you can simply execute the current subscription invoice. In other words, accelerate the current billing period to end at the moment just prior to cancelation. You can do this by simply changing the bill date on the current invoice. See the changeBillDate parameter here.

  2. 2 Posted by Michael van Roo... on 29 Aug, 2011 04:53 PM

    Michael van Rooijen's Avatar

    Hi Marc,

    You bring up good points. So basically what you recommend is that when a user deletes his/her account, I simply cancel the users subscription on CG. But before cancellation I update the Bill date to for example "1 day ago" and then cancel the subscription?

    I assume that even if the users' account is in a canceled state, and the bill date was set to a date in the past (but not yet marked as billed) that CG will still bill the customer then?

    So if i do the following:

    • User is about to delete account
    • Bill date gets set to "1 day ago"
    • User's CG account gets canceled, but not deleted

    Even though there's maybe only 2-3 seconds between the last 2 actions, it would still work and charge the customer the remaining usage?

    One last question if taking this approach. I'm currently using the user's database id as the identifier for their CG customer account. If a user deletes his/her account from my app, their "id" is also lost, so if they later decide to come back, the id will have changed. I assume it would create a new customer on CG when a new subscription is made, since their id changed. But would that matter or cause issues with either CG or PayPal? Maybe because their email address is already being used or is already subscribed (although canceled) to CheddarGetter/My App.

    Thanks for the great advice!

  3. Support Staff 3 Posted by Marc Guyer on 29 Aug, 2011 08:14 PM

    Marc Guyer's Avatar

    You bring up good points. So basically what you recommend is that when a user deletes his/her account, I simply cancel the users subscription on CG. But before cancellation I update the Bill date to for example "1 day ago" and then cancel the subscription?

    Yes, just update the date with the word "now" and the transaction will be executed immediately, giving you feedback about whether or not the transaction was approved. Upon an approved transaction, cancel. Otherwise... ?

    I assume that even if the users' account is in a canceled state, and the bill date was set to a date in the past (but not yet marked as billed) that CG will still bill the customer then?

    No, if a customer is canceled, they will not be billed. If an invoice was due before cancelation, the subscription must be reactivated in order to bill the invoice.

    But would that matter or cause issues with either CG or PayPal? Maybe because their email address is already being used or is already subscribed (although canceled) to CheddarGetter/My App.

    I don't foresee any problems here. There are no restrictions on customers having the same email address. You can have as many "subscriptions" in PayPal on the same account, too.

  4. 4 Posted by Michael van Roo... on 29 Aug, 2011 09:38 PM

    Michael van Rooijen's Avatar

    Thanks, I'll give it a shot!

  5. Marc Guyer closed this discussion on 29 Aug, 2011 09:44 PM.

Discussions are closed to public comments.
If you need help with Cheddar please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

28 Mar, 2024 10:45 PM
24 Jan, 2024 08:33 AM
11 Jan, 2024 07:13 AM
30 Nov, 2023 02:07 AM
22 Nov, 2023 08:41 AM