stripe-payments

Stripe Add multiple card to Same User

Create customer in stripe

public function createCustomer($data , $token)//pass form data and token id
{
    $customer=Customer::create(array(
    "email"=>$data['email'],
    "description" => $data['name'],
    "source" => $token // obtained with Stripe.js
    ));
    return $customer['id'];
}

For more Information follow this Link

How to retrive customer And add cards in Stripe

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;
}

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow