Changes to Autobills in the FreshBooks API

As of january 1st freshbook will no longer be accepting raw cc data. You need to pass token instead of card number when you create recurring profile.

The new required flow follows this sequence:

  1. create a client
  2. send raw credit card data to our secured tokenization service, receive a token
  3. create a recurring profile with the token you received instead of a card number
  4. the recurring profile processes credit cards automatically as scheduled

PHP Code to create token:

$card_number = 'YOUR CARD NUMBER';
$card_name = 'YOUR NAME IN THE CARD';
$exp_month = 'EXPIRY MONTH - MM FORMAT';
$exp_year = 'EXPIRY YEAR - YYYY FORMAT';

$cc_info = json_encode(
array('cc_info' => array(
'card_number'=> $card_number,
'name' => $card_name,
'expiry_month' => $exp_month,
'expiry_year' => $exp_year
$tokenurl = "";
$ch = curl_init($tokenurl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $cc_info);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($cc_info))
$tokenResponse = curl_exec($ch);
$res = json_decode($tokenResponse, true);
$cc_token = $res['cc_token'];