Nova Framework, Tutorials, Stripe API

Stripe API updating credit card stored in Stripe

There will be times customers need to update their stored credit card, this post goes over how to enable that.

I’m using Nova Framework not setup with Nova? please read Getting Stripe API setup with Nova Framework

first get the customers information, if you don’t have this method please read Stripe API get customer information

$customer = $this->getCustomer();

Next using checkout prefix a Stripe button, notice the use of $ustomer->default_source->last4 this displayed the last 4 digits of the card. It’s not required but is useful.

<form action="{{ site_url('account/updatecard') }}" method="POST">
src="" class="stripe-button"
data-key="{{ Config::get('stripe.apiPublicKey') }}"
data-email='{{ Auth::user()->email }}'
data-name="{{ Config::get('') }}"
data-panel-label="{{ __d('users', 'Update Card Details') }}"
data-label="{{ __d('users', 'Update Card') }} ({{ $customer->default_source->last4 }})"

Have this post to e page to save the changes.

In the post create an instance of the customer then update the source and save the changes.

//update card source
$customer = $this->getCustomer();
$customer->source = Input::get('stripeToken');

This will update the card stored on Stripe, like with a subscription the card details won’t be on your server.

David Carr

David Carr

For the past 12 years, I’ve been developing applications for the web using mostly PHP. I do this for a living and love what I do as every day there is something new and exciting to learn.

In my spare time, the web development community is a big part of my life. Whether managing online programming groups and blogs or attending a conference, I find keeping involved helps me stay up to date. This is also my chance to give back to the community that helped me get started, a place I am proud to be apart of.

Besides programming I love spending time with friends and family and can often be found together going out catching the latest movie, staying in playing games on the sofa or planning a trip to someplace I’ve never been before.