# Card on file using PHP

**URL:** <https://developer.squareup.com/forums/t/card-on-file-using-php/9109>\
**Category:** Questions\
**Created:** [April 5, 2023, 2:04am UTC](https://developer.squareup.com/forums/t/card-on-file-using-php/9109 "2023-04-05T02:04:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![luenib](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@luenib](https://developer.squareup.com/forums/u/luenib)\
**Post date:** [April 5, 2023, 2:04am UTC](https://developer.squareup.com/forums/t/card-on-file-using-php/9109/1 "2023-04-05T02:04:29Z")

</div>

Hi,

I’m using PHP and I’d like to create a form where a client could add a credit card to his file.

The client should be able to enter CC#, expiration date, CVV, and zip code. Is that even possible?

Thanks.

---

<div class="post-metadata">

**Author:** ![BrianC](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/brianc/32/112_2.png) [@BrianC](https://developer.squareup.com/forums/u/BrianC)\
**Post date:** [April 5, 2023, 11:02am UTC](https://developer.squareup.com/forums/t/card-on-file-using-php/9109/2 "2023-04-05T11:02:14Z")

</div>

Is this walkthrough what you’re looking for?

> **[Create a Card on File and a Payment](https://developer.squareup.com/docs/cards-api/walkthrough-seller-card)**
>
> This procedure is used when your Square account is a seller account and your application uses only a seller account access token.

This walkthrough has 3 steps - (1) create customer; (2) save card on customer; (3) use saved card for a transaction.

Obviously you’d save the card (steps 1 and 2) and then stop; and then when they came back to pay you’d follow step 3 (using the card-on-file token that you saved from step 2) in the walkthrough.

---

<div class="post-metadata">

**Author:** ![luenib](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@luenib](https://developer.squareup.com/forums/u/luenib)\
**Post date:** [April 5, 2023, 11:28pm UTC](https://developer.squareup.com/forums/t/card-on-file-using-php/9109/3 "2023-04-05T23:28:15Z")

</div>

Thanks.

The customer already exists, and I don’t need to process a payment. So, yes, I only need to work on step 2. The problems is that I don’t see the code to render the credit card form where the client can type the CC info.

Regards.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [April 6, 2023, 12:22am UTC](https://developer.squareup.com/forums/t/card-on-file-using-php/9109/4 "2023-04-06T00:22:47Z")

</div>

The form for the customer to input their card information is [The Web Payments SDK](https://developer.squareup.com/docs/web-payments/overview). Instead of passing the generated token in to the CreatePayment request you instead pass it to the CreateCard to generate the card on file. 🙂

---

<div class="post-metadata">

**Author:** ![luenib](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@luenib](https://developer.squareup.com/forums/u/luenib)\
**Post date:** [April 8, 2023, 9:39pm UTC](https://developer.squareup.com/forums/t/card-on-file-using-php/9109/6 "2023-04-08T21:39:44Z")

</div>

I folowing the instrucctions here:

> **[Store a Card on File with SCA](https://developer.squareup.com/docs/web-payments/sca-add-card)**
>
> Learn about adding a card on file with Strong Customer Authentication (SCA).

The Console returns this:  
POST [https://my.website.com/card](https://my.website.com/card) 404

That’s line 10 in “Step 3: Add the card on file method”

Should I replace “fetch(‘/card’,” with something else?

Thanks

---

<div class="post-metadata">

**Author:** ![luenib](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@luenib](https://developer.squareup.com/forums/u/luenib)\
**Post date:** [April 8, 2023, 9:51pm UTC](https://developer.squareup.com/forums/t/card-on-file-using-php/9109/7 "2023-04-08T21:51:09Z")

</div>

Since I’m not using Node, It looks like I’ll have to write something in PHP that runs in the path contained in fetch. Is that correct?

---

<div class="post-metadata">

**Author:** ![luenib](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@luenib](https://developer.squareup.com/forums/u/luenib)\
**Post date:** [April 9, 2023, 1:51am UTC](https://developer.squareup.com/forums/t/card-on-file-using-php/9109/8 "2023-04-09T01:51:11Z")

</div>

I finally got it to work.

Thanks.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [April 10, 2023, 4:02pm UTC](https://developer.squareup.com/forums/t/card-on-file-using-php/9109/9 "2023-04-10T16:02:01Z")

</div>

Glad to hear that you got it to work. 🙂
