# Square Online Checkout -\> APIs with Card on File

**URL:** <https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904>\
**Category:** Questions\
**Created:** [October 4, 2023, 3:06am UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904 "2023-10-04T03:06:17Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![johnblythe](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/johnblythe/32/2339_2.png) [@johnblythe](https://developer.squareup.com/forums/u/johnblythe)\
**Post date:** [October 6, 2023, 9:54pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/21 "2023-10-06T21:54:28Z")

</div>

> [@Bryan-Square](#):
>
> card\_on\_file

i’m not sure i understand.

maybe we weren’t aligned on the two workflow replies we had above? [here](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/5) and [here](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/6)?

i ordered via Checkout. punched in a brand new card. paid successfully. the `payment.created` webhook fired. is that what i should be able to use an `id` from or no?

if it was `card_on_file` that’s not something i can change, is it? since it’s part of what Square obfuscates from developers in the Checkout + API usage.

thanks for continuing to dive in, i just really need at this point to figure out if Checkout + API is viable or i have to use the SDK to create our own secondary part of the user experience so we can get cranking on delivery.

thanks!

---

<div class="post-metadata">

**Author:** ![johnblythe](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/johnblythe/32/2339_2.png) [@johnblythe](https://developer.squareup.com/forums/u/johnblythe)\
**Post date:** [October 6, 2023, 9:55pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/22 "2023-10-06T21:55:10Z")

</div>

extra clarity: i _did_ punch in the card when checking out. it was a brand new card i’ve never used with Square before. i _did_ use my usual email address that Square knows me by.

---

<div class="post-metadata">

**Author:** ![johnblythe](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/johnblythe/32/2339_2.png) [@johnblythe](https://developer.squareup.com/forums/u/johnblythe)\
**Post date:** [October 9, 2023, 6:09pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/23 "2023-10-09T18:09:13Z")

</div>

> [@Bryan-Square](#):
>
> Looks like the payment `jffuztfumrVLqnZCdltvEdA4njSZY` method you use to process the payment was `card_on_file`. You can’t create a card on file with a payment that’s card on file. You’ll need to key the card in. 🙂

hi @Bryan-Square can you help clarify this one for me please? if it’s something i can resolve i’d love to but i don’t understand where our gap is on what i was doing vs. what you suggested vs. whatever caused the issue

---

<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:** [October 9, 2023, 7:51pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/24 "2023-10-09T19:51:31Z")

</div>

I haven’t been able to replicate what you say you experienced. If you try paying for a $1.00 payment link again by keying the card in. When you call [GetPayment](https://developer.squareup.com/reference/square/payments-api/get-payment) with the `payment_id` what is the `entry_method` show? 🙂

---

<div class="post-metadata">

**Author:** ![johnblythe](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/johnblythe/32/2339_2.png) [@johnblythe](https://developer.squareup.com/forums/u/johnblythe)\
**Post date:** [October 9, 2023, 8:38pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/25 "2023-10-09T20:38:06Z")

</div>

To be clear, a payment link is different than the Checkout product isn’t it? I’m using the Online product’s Checkout feature.

---

<div class="post-metadata">

**Author:** ![johnblythe](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/johnblythe/32/2339_2.png) [@johnblythe](https://developer.squareup.com/forums/u/johnblythe)\
**Post date:** [October 9, 2023, 9:11pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/26 "2023-10-09T21:11:32Z")

</div>

this is where i land right before final payment. this is where i put a new card number into.

 ![image](https://global.discourse-cdn.com/square/original/2X/b/bbac13d964697265c48081a0105afa94b41bbf99.jpeg)

what i need to know to determine how we proceed w this project is if can i grab a `payment` event from this `/checkout` screen (post payment/completion) and associate w a `customer` or not for future payments (authorized by them by the modifier they chose in the shopping experience).

if not, then it seems i’ll have to build out something else around the SDK. not ideal but doable.

i’m stuck until that is confirmed and proven 😕

---

<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:** [October 9, 2023, 9:22pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/27 "2023-10-09T21:22:05Z")

</div>

You won’t get a payment from that checkout page since its the Square Online Store, but you will get a webhook event when the customer pays for this if your subscribed to the event. 🙂

---

<div class="post-metadata">

**Author:** ![johnblythe](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/johnblythe/32/2339_2.png) [@johnblythe](https://developer.squareup.com/forums/u/johnblythe)\
**Post date:** [October 9, 2023, 9:34pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/28 "2023-10-09T21:34:43Z")

</div>

yes and that’s what i used to produce the results above that didn’t work. i’m not sure where we’re missing each other but it seems like we’ve lost the trail and i’m unsure how to get it back on track at this point :\

---

<div class="post-metadata">

**Author:** ![johnblythe](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/johnblythe/32/2339_2.png) [@johnblythe](https://developer.squareup.com/forums/u/johnblythe)\
**Post date:** [October 9, 2023, 9:37pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/29 "2023-10-09T21:37:44Z")

</div>

starting fresh to try to get back on the same page.

- user checkouts on a checkout page
- i catch a webhook – `payment.created`
- i use that to get an `order` via `order_id`
- the `order` object has a `customer_id` i can use to get the customer
- when i use the `payment.id` and the `customer.id` to try to create a card i get the error [i listed above](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/15)

is that something i can get around? [your reply here](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/20) didn’t make sense to me because i used a brand new card in checkout.

does this all make sense? what else can i offer or answer to help fill in gaps and get to a decision on if we can use checkout + API for our use case? 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:** [October 9, 2023, 9:47pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/30 "2023-10-09T21:47:39Z")

</div>

The flow is:

- customer checkouts on a checkout page
- You catch a webhook – `payment.created`
- You use that to get a `payment` via `payment_id`
- If the payments `entry_method` is `card on file` then you can use that card on file for any future payment. If it’s `keyed` then use the `customer_id` in the payment to GetCustomer to see if the customer has a card on file.  
\*If not then CreateCard with the `payment_id`.

What was the payment\_id you used to get the error? Also when you call GetPayment with the `payment_id` what is the `entry_method`? 🙂

---

<div class="post-metadata">

**Author:** ![johnblythe](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/johnblythe/32/2339_2.png) [@johnblythe](https://developer.squareup.com/forums/u/johnblythe)\
**Post date:** [October 9, 2023, 10:00pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/31 "2023-10-09T22:00:16Z")

</div>

same one [listed here](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/15) and you had used (or just mentioned?) [here](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/20)

[how/what did you use here](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/14) to get it to work?

---

<div class="post-metadata">

**Author:** ![johnblythe](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/johnblythe/32/2339_2.png) [@johnblythe](https://developer.squareup.com/forums/u/johnblythe)\
**Post date:** [October 9, 2023, 10:01pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/32 "2023-10-09T22:01:41Z")

</div>

entry method does say `ON_FILE`. is it because square stored it for me bc it knows my email? or did i have a prompt that i had hit ‘yes’ to saving it? it’s a brand new card i’d just gotten so i used it to try to _avoid_ square using my prior card/profile

---

<div class="post-metadata">

**Author:** ![johnblythe](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/johnblythe/32/2339_2.png) [@johnblythe](https://developer.squareup.com/forums/u/johnblythe)\
**Post date:** [October 9, 2023, 10:03pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/33 "2023-10-09T22:03:12Z")

</div>

> [@johnblythe](#):
>
> `8ZE7FH29YD1GZDPK0WMAJ3XB04`

when i look up the customer via `retrieveCustomer` and using the `id` i don’t see any payment information. how can i get that from a customer who may already have an `ON_FILE` method?

using `listCards` w a `customerId` pulls back a `{}` response. i can’t see anything else at the moment in API Explorer that would seem to be promising for getting my on file card :\

---

<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:** [October 9, 2023, 10:05pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/34 "2023-10-09T22:05:29Z")

</div>

If you call GetPayment with `jffuztfumrVLqnZCdltvEdA4njSZY` what does the `entry_method` say? If it says `ON_FILE` the call to `CreateCard` will fail with that `payment_id`.

---

<div class="post-metadata">

**Author:** ![johnblythe](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/johnblythe/32/2339_2.png) [@johnblythe](https://developer.squareup.com/forums/u/johnblythe)\
**Post date:** [October 9, 2023, 10:17pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/35 "2023-10-09T22:17:04Z")

</div>

😆 we’re still missing each other 🙃 😢

`ON_FILE`

> [@Square Online Checkout -\> APIs with Card on File](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/32):
>
> entry method does say ON\_FILE. is it because square stored it for me bc it knows my email? or did i have a prompt that i had hit ‘yes’ to saving it? it’s a brand new card i’d just gotten so i used it to try to avoid square using my prior card/profile

and then as a result i’m trying to find a different way about it ([this post](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/33))

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:** [October 9, 2023, 10:28pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/36 "2023-10-09T22:28:03Z")

</div>

If you try another payment does it come over as `ON_FILE`? Or if you use a different card is the `entry_method` `KEYED`? I haven’t been able to replicate what your seeing. Every payment I try it’s `KEYED`. 🙂

---

<div class="post-metadata">

**Author:** ![johnblythe](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/johnblythe/32/2339_2.png) [@johnblythe](https://developer.squareup.com/forums/u/johnblythe)\
**Post date:** [October 10, 2023, 12:12am UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/37 "2023-10-10T00:12:52Z")

</div>

amazing. got things connecting finally, ty. i had to make sure to `continue as guest` for it to work.

is there any way to handle this for people who have used Square Checkout before and are `ON_FILE` for Square but not the merchant? or will we have to notice that status and manually bump them to somehow give us a different keyed version (through SDK? something else?)?

thanks!

---

<div class="post-metadata">

**Author:** ![johnblythe](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/johnblythe/32/2339_2.png) [@johnblythe](https://developer.squareup.com/forums/u/johnblythe)\
**Post date:** [October 10, 2023, 9:09pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/38 "2023-10-10T21:09:35Z")

</div>

is there a way to get card info from users who are signed in to Square @Bryan-Square ? i could only use the payment.id when i was a guest bc otherwise it’d send my data over as `ON_FILE` method

---

<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:** [October 10, 2023, 10:32pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/39 "2023-10-10T22:32:06Z")

</div>

Not sure I fully understand. What do you mean by signed in? 🙂

---

<div class="post-metadata">

**Author:** ![johnblythe](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/johnblythe/32/2339_2.png) [@johnblythe](https://developer.squareup.com/forums/u/johnblythe)\
**Post date:** [October 10, 2023, 11:05pm UTC](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904/40 "2023-10-10T23:05:14Z")

</div>

the method you described way above only works if i choose to `continue as guest`. if i do the verification process via a square code texted to me it will use a method of `ON_FILE`. HOWEVER, that card is _not_ on file for this merchant. if i use the search customer endpoint w that email or phone number, i cannot use the retrieved customer id to get listed cards. (i _couldn’t_, now i can after doing the `as guest` method, that’s how i was able to test and confirm your original solution)

does that make sense? it seems Square had my card on file even tho the merchant didn’t, so even tho i keyed in my card it stored it and used `ON_FILE` until i `continued as guest`.

thanks-

[Previous page](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904.md?page=1)

[Next page](https://developer.squareup.com/forums/t/square-online-checkout-apis-with-card-on-file/10904.md?page=3)
