First time I am working with Payment System with PHP and Stripe API.

I have html form where user can Add their credit card info. Form fields are bellow :

  1. Card Number
  2. Month
  3. Year
  4. CVC

I can successfully add user credit card to my stripe account as Customer Account.

Now After added the credit card and I can get the card details using stripe API and...

  • Is it require to show the credit card number to the form field called Card Number ?

  • If so, then I can't see any full credit card number, I can see one of stripe object called last4. I know it's a last 4 digit of user credit card

  • Okey, If I show only 4 digit to the Card Number field then when I update the form It's showing The card number is not a valid credit card number. because the field is only showing 4 digit

  • If I again enter my card number to that Card Number field then it's successfully updated.

Now how can I update the user credit card without again enter the credit card number to the Card Number field ?

Update :

This is the Payment information form image : enter image description here

and Update Code is following :

$updateCustomer = \Stripe\Customer::retrieve("$acc_id");
$updateCustomer->description = "Customer account of $fname_db $lname_db - #$u_id ($accountFor Account)";
$updateCustomer->source = "$stripToken";
$updateCustomer->save();        
upvote
  flag
i think your looking for something like: support.stripe.com/questions/… – nogad
upvote
  flag
@nogad I can add, update and can get the customer details with all info from my stripe account. But my questions is. Is it require to show the full credit number to the form ? If Yes, then I can't see full credit card number. If no, then user have to again enter their credit card number to update the payment details ? – shibbir ahmed
upvote
  flag
i dont know what "form" your talking about. – nogad
upvote
  flag
I have a website where in user profile section user can add their credit card details. I am using a html for to add credit card details. – shibbir ahmed
upvote
  flag
yes, as the document above shows you can use the api, once you have the details once "Second, with our API: You just need to attach the card details to a customer object. Once you’ve done that, you can charge the customer at any time." – nogad
upvote
  flag
Is the api response is showing full credit card number ? – shibbir ahmed
upvote
  flag
no it shouldn't, but you dont need the number(only stripe needs to know it) – nogad
upvote
  flag
then when I submit the form either card number field will be empty or last 4 digit. What happened then ? – shibbir ahmed
upvote
  flag
you dont re use your form, you use their api. read the above link again, its exactly what you want to use – nogad
upvote
  flag
I have updated my questions. You can see the form image and how I update the user existing credit card – shibbir ahmed
3 upvote
  flag
NEVER Store the customers credit card number on your site, you're asking for trouble. Stripe will store this in their API. If you want to emulate some section where the user can change their card number, then get the last 4 digits back from Stripe and pad the rest of the number with **** **** **** 9424, from a UX perspective the customer can see, "oh this is my card identified by the last 4 digits, looks like I can update it here too" – Alex

1 Answers 11

By design, Stripe's API will not return the full card number. Unless you are PCI certified yourself, your server should never have access to the full card numbers.

In order to create a charge using a saved customer, you simply need to pass the customer ID in the customer parameter.

This tutorial explains how to create customers then create charges using the customers.

Not the answer you're looking for? Browse other questions tagged or ask your own question.