Reactivation After Expired Trial Auto-Cancel

michael.roth's Avatar

michael.roth

28 Jun, 2013 02:10 PM

This comment was split from the discussion: Request Signature Verification

Hey Marc,

I have a question I was wondering if I could get your help on. We're trying to work through a scenario and wanted to get your take on it. So the scenario is that a user signs up for our product on July 1st and gets an invoice built in CG for a billing date of July 14th when his 14 day trial period ends. The user doesn't end up using the product and never inserts his billing information, so on July 14th CG cancels the customer and doesn't run the invoice. Then a month passes by and the user decides that he wants the product now. He re-signs in to our product and inserts his billing information which gets sent to CG. So the previous CG invoice gets run and CG creates the recurring next invoice for a bill date of the next year. Our question is when that previous invoice gets runs does the next invoice get a billing date of a July 14th 2014, which is a year from the bill date of the first invoice, or is it a year from the day that the invoice got ran, which was August 1st. For our situation we would want the next invoice bill date to be a year from when the invoice ran, so August 1st 2014, not July 1st 2014. If you could give us some guidance on what the dates will be set to and what we might do to update the dates that would be great.

Thanks again for the help,
Michael

  1. 1 Posted by Dean on 28 Jun, 2013 08:04 PM

    Dean's Avatar

    Hi Michael,

    Our question is when that previous invoice gets runs does the next invoice get a billing date of a July 14th 2014, which is a year from the bill date of the first invoice, or is it a year from the day that the invoice got ran, which was August 1st.

    The next invoice will be one billing frequency period from the billingDatetime, not from when the invoice was actually transacted. So, in this case the next invoice's billDate will be July 14th, 2014.

    To achieve your desire of an August 1st billDate, you can use the API to update a subscription and change its billDate. You could setup some logic in your app to change billDate's for customers based on their transactedDatetime instead of their billDatetime. I'm not an expert on that process, but if you need more explanation I would be happy to find out for you!

    All the best,
    Dean

  2. Support Staff 2 Posted by Marc Guyer on 28 Jun, 2013 09:01 PM

    Marc Guyer's Avatar

    Hi Michael -- This is considered to be a "long cancel". The documentation for reactivations is here:

    http://support.cheddargetter.com/kb/operational-how-tos/what-happen...

    In the case of an auto-cancel for non payment at the end of a trial, then a reactivation after that trial expires, it's somewhat like a new signup. So, the trial starts over again. You can override this behavior by passing in the param changeBillDate=now to the API.

    I'd suggest running through a test. You can simulate this by setting the initial bill date to, say, a few minutes from now. Then, wait for the CG recurring engine to pick it up for billing (up to 3 hours) -- this is when the auto-cancel will occur. Then, do the reactivation.

  3. 3 Posted by michael.roth on 02 Jul, 2013 08:40 PM

    michael.roth's Avatar

    Hey Marc,

    We finally figured out how to get the authentication to work on our app. Here is the code if you want to put on the CG documentation page.

    Thanks
    Michael

    var authorizationHeader = request.Headers["X-CG-SIGNATURE"];

    if (string.IsNullOrEmpty(authorizationHeader))
    {
    throw new Domain.Exceptions.Exception();
    }

    request.InputStream.Seek(0, SeekOrigin.Begin);

    using (var reader = new StreamReader(request.InputStream))
    {
    // Read The Entire Body In
    var httpBody = reader.ReadToEnd();
    // Get Token
    var token = CalculateMd5Hash(httpBody);
    // Get SHA256 HMAC Hash of the MD5 hash using my secret key as the salt
    var sha256String = CalculateSha256Hash(_secretKey, token);
    // Check Against The Authorization Header
    if (sha256String != authorizationHeader)
    {
    throw new Domain.Exceptions.Exception();
    }
    }

    public string CalculateMd5Hash(string input)
    {
    // fire up a new MD5 creator
    var md5 = MD5.Create();
    // convert input to a byte array
    var inputBytes = Encoding.ASCII.GetBytes(input);
    // get the byte array hash
    var hash = md5.ComputeHash(inputBytes);

    // convert the byte array to a string and return
    var sb = new StringBuilder();
    for (var i = 0; i < hash.Length; i++)
    {
    sb.Append(hash[i].ToString("x2"));
    }
    return sb.ToString();
    }

    public string CalculateSha256Hash(string secretKey,string md5)
    {
    // Get The Byte Array of My Secret Key
    var secretKeyArray = Encoding.ASCII.GetBytes(secretKey);
    // Build A SHA256 Hash Creator Using My Secret Key as the key
    var hash = new HMACSHA256(secretKeyArray);
    var byteArray = hash.ComputeHash(Encoding.ASCII.GetBytes(md5));

    // convert the byte array to a string and return
    var sb = new StringBuilder();
    for (var i = 0; i < byteArray.Length; i++)
    {
    sb.Append(byteArray[i].ToString("x2"));
    }
    return sb.ToString();
    }

  4. 4 Posted by Dean on 02 Jul, 2013 08:43 PM

    Dean's Avatar

    Michael -- Thanks a lot for this! The CG community will benefit greatly from your contribution.

  5. Jess Pendley closed this discussion on 21 Nov, 2013 07:45 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