public function addCard($cust_id, $token)
{
$retriveResult=Customer::retrieve($cust_id);
$tokendata = Token::retrieve($token);
$newcard = $tokendata['card'];
$flag = 1;
foreach ($retriveResult['sources']['data'] as $card) {
if($card['fingerprint'] === $newcard['fingerprint'])
{
$cardid = $card['id'];
$flag = 0;
break;
}
}
if($flag)
{
$savecard = $retriveResult->sources->create(array("source" =>$token));
$cardid = $savecard['id'];
}
return $cardid;
}