Jump to content

Stripe "Smarter Saved Cards" feature to auto update customer's card


ScottN

Recommended Posts

Stripe has an awesome feature that will automatically update a customer's card, if the bank replaces the card (new number, or just new expiration date).  However, there is no notification from Stripe to WHMCS that this has occurred.  So, we show an expired card in WHMCS, but Stripe is perfectly happy and would allow you to charge the customer's card just fine (but WHMCS won't even try).  

I can't seem to find any talk about this feature, and I'm not sure why... it would be reduce customer churn and improve customer service.

This feature from Stripe has been around for 4 years+.  Here is an article about their "Smarter Saved Cards" feature from 2015:

https://stripe.com/blog/smarter-saved-cards

It says "The customer.source.updated webhook will fire if your customers’ info changes." --  could WHMCS listen for this and do something to update itself about the new card?

Thoughts?

- Scott

Link to comment
Share on other sites

12 hours ago, ScottN said:

Thoughts?

my initial thought is that it was a pity you didn't post this in the v7.7 beta forums last month as it might have had a remote chance of being acted upon quickly if it only required a minor tweak to the Stripe module... but v7.7 beta development has supposedly closed to new features now, so that avenue is not really an option now.

effectively, I think you're looking at creating a feature request (yeah I know!) and waiting for WHMCS to act on it... if you create it, perhaps post the link in this thread (the requests can be notoriously difficult to find and that's one of the reasons they hardly get voted for - or you end up seeing multiple similar requests with a couple of votes each).

Link to comment
Share on other sites

  • 3 weeks later...

Feature Request has been added and approved by WHMCS:

https://requests.whmcs.com/topic/add-support-for-stripe-smarter-saved-cards-to-automatically-update-cc-number-andor-exp-date

I think we just need WHMCS to create a script in /modules/gateways/callback/ to listen for Stripe to tell us about a card update (and point Stripe to that 'webhook' location)... then take that info (which includes the last 4 of the card, the month and year) and update the info we store in WHMCS.  

- Scott

Link to comment
Share on other sites

You could dev your own callback file to take those actions.  For example (not tested):

 
// Retrieve the request's body and parse it as JSON:
$input = @file_get_contents('php://input');
$event = json_decode($input);
 
if (isset($event->type) and $event->type == "customer.source.updated" )
{
    // fetch customer from whmcs either by getting customer from stripe and get email and then search or grab from database 
    $results = localAPI("UpdateClient", [clientid=>1, 'expdate'=>$event->data->object->exp_month.$event->data->object->exp_year] );
}
//return http code to stripe to give it success or failure
http_response_code(200); // PHP 5.4 or greater

EDIT: You will also want to verify the event with stripe before taking action. 

Edited by steven99
Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated