更新Stripe上的主信用卡以供用户使用

I'm trying to update the main credit card on Stripe for a user.

My form is :

<form id="update-card-form">
    <div class="modal-body">
        <div class="col-md-12">
            <div class="form-group">
                <label for="text-input">Credit card number</label>
                <input type="number" data-stripe="number" class="form-control">
            </div>
        </div>
        <div class="col-md-6">
            <label for="text-input form-group col-md-12">Expiration date</label>
            <div class="form-group col-md-6">
                <input type="number" data-stripe="exp-month" class="form-control" placeholder="MM">
            </div>
            <div class="form-group col-md-6">
                <input type="number" data-stripe="exp-year" class="form-control" placeholder="YYYY">
            </div>
        </div>
        <div class="col-md-6">
            <div class="form-group">
                <label for="text-input">Security number</label>
                <input type="number" data-stripe="cvc" class="form-control">
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-primary" id="update-card-button"> Save</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    </div>
</form>

I do not know how can I call the Stripe API to update the main credit card on the customer side.


I have actually the credit card id and the customer id.

\Stripe\Stripe::setApiKey("your_stripe_api_key");

$cu = \Stripe\Customer::retrieve("cusomter_id_here");
$card = $cu->sources->retrieve("card_id_here");
$card->name = "Jane Austen";
$card->save();

more info in stripe documentation https://stripe.com/docs/api/php#update_card

edit you can update only address fields(e.g. address city, address_line1 etc), exp month, year, the name and the metadata.