# Square Payment Api

**URL:** <https://developer.squareup.com/forums/t/square-payment-api/12003>\
**Category:** Questions\
**Tags:** payments-api\
**Created:** [February 1, 2024, 1:57am UTC](https://developer.squareup.com/forums/t/square-payment-api/12003 "2024-02-01T01:57:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Start909Developer](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@Start909Developer](https://developer.squareup.com/forums/u/Start909Developer)\
**Post date:** [February 1, 2024, 1:57am UTC](https://developer.squareup.com/forums/t/square-payment-api/12003/1 "2024-02-01T01:57:35Z")

</div>

I am having issues with the payment api for customers on file. I am able to obtain the source ID but the actual creation of payment is failing in production even though it was working in sandbox. I have updated the tokens for production. I have also verfied the cutsomer\_id. I just don’t know what I am doing wrong. Here is my request random\_uuid = uuid.uuid4()  
idempotency\_key = f"{int(time.time())}\_{str(random\_uuid)[:15]}"

```
                response = square_client.payments.create_payment(
                    body={
                        "source_id": "ccof:customer-card-id-ok",
                        "idempotency_key": idempotency_key,
                        "amount_money": {
                            'amount': amount_in_cents,
                            'currency': 'USD',
                        },
                        "autocomplete": False,
                        "customer_id": customer_id,
                        "accept_partial_authorization": False
                  

                    }

                )

```

And the Response {  
“errors”: [  
{  
“code”: “NOT\_FOUND”,  
“detail”: “Did not find matching card”,  
“field”: “source\_id”,  
“category”: “INVALID\_REQUEST\_ERROR”  
}  
]  
}. My Square ID is sq0idp-2fg-YHsBRXzYeZT3EjRZXA

---

<div class="post-metadata">

**Author:** ![Square-Dev-AI](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/square-dev-ai/32/2513_2.png) [@Square-Dev-AI](https://developer.squareup.com/forums/u/Square-Dev-AI)\
**Post date:** [February 1, 2024, 1:57am UTC](https://developer.squareup.com/forums/t/square-payment-api/12003/2 "2024-02-01T01:57:56Z")

</div>

👋 I’m Square Dev AI, here to help answer your question!  
Based on the information you’ve provided, the following documentation will help answer your question:

> **[Create a Card on File from a Payment ID](https://developer.squareup.com/docs/cards-api/walkthrough/card-from-payment-id)**
>
> Learn how to create a new card on file in a Square account using a Payment ID as a source.

> **[Charge Cards on File](https://developer.squareup.com/docs/reader-sdk/cookbook/charge-cards-on-file)**
>
> Create a seamless purchase experience for returning customers and enable recurring payments.

> **Additional Documentation**
>
> [Create and Publish Invoices](https://developer.squareup.com/docs/invoices-api/walkthrough)  
> [Card Payments](https://developer.squareup.com/docs/payments-api/take-payments/card-payments)  
> [Create a Card on File and a Payment](https://developer.squareup.com/docs/cards-api/walkthrough-seller-card)

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.  
Otherwise one of our Developer Advocates will provide additional assistance shortly.

---

<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:** [February 1, 2024, 4:40pm UTC](https://developer.squareup.com/forums/t/square-payment-api/12003/3 "2024-02-01T16:40:30Z")

</div>

When testing in production are you using a valid card, because the value that you have in the code example `ccof:customer-card-id-ok` is a sandbox test value. 🙂

---

<div class="post-metadata">

**Author:** ![Start909Developer](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@Start909Developer](https://developer.squareup.com/forums/u/Start909Developer)\
**Post date:** [February 1, 2024, 11:15pm UTC](https://developer.squareup.com/forums/t/square-payment-api/12003/4 "2024-02-01T23:15:02Z")

</div>

Bryan, thank you for the reply. I assumed that was a standard call for a Credit Card on File because API Explorer was doing the same thing in production mode. Obviously I did not go past generating the api call on there. So what replaces it in a production environment?

---

<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:** [February 2, 2024, 12:16am UTC](https://developer.squareup.com/forums/t/square-payment-api/12003/5 "2024-02-02T00:16:17Z")

</div>

You’ll need to pass in the `card_id` that was first generated by the Cards API for the customer profile. If you [RetrieveCustomer](https://developer.squareup.com/reference/square/customers-api/retrieve-customer) with the `customer_id` the profile will have the `card_id` that you’ll pass into the `CreatePayment` request when trying to charge a card on file. 🙂

---

<div class="post-metadata">

**Author:** ![Start909Developer](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@Start909Developer](https://developer.squareup.com/forums/u/Start909Developer)\
**Post date:** [February 3, 2024, 4:36am UTC](https://developer.squareup.com/forums/t/square-payment-api/12003/6 "2024-02-03T04:36:01Z")

</div>

I see! Thanks for your assistance Bryan! Cheers! 👍 🙏

---

<div class="post-metadata">

**Author:** ![Start909Developer](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@Start909Developer](https://developer.squareup.com/forums/u/Start909Developer)\
**Post date:** [February 5, 2024, 3:45pm UTC](https://developer.squareup.com/forums/t/square-payment-api/12003/7 "2024-02-05T15:45:14Z")

</div>

I am facing another issue. I have successfully processed a payment, got all the approval responses including receipt number. But the transaction is not in my production dashboard. Tried \* **Reporting** \> **Transactions**.

- Select **eCommerce Integrations** from the _All Payment Methods_ dropdown. Still nothing. It is not reflected in my balance either. What am I missing?

---

<div class="post-metadata">

**Author:** ![Start909Developer](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@Start909Developer](https://developer.squareup.com/forums/u/Start909Developer)\
**Post date:** [February 5, 2024, 5:04pm UTC](https://developer.squareup.com/forums/t/square-payment-api/12003/8 "2024-02-05T17:04:34Z")

</div>

I solved the issue. Autocomplete was set to ‘false’, hence creating a delayed process. Thanks for your assistance. I am closing this as solved.

---

<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:** [February 5, 2024, 8:31pm UTC](https://developer.squareup.com/forums/t/square-payment-api/12003/9 "2024-02-05T20:31:30Z")

</div>

Glad to hear you figured it out. 🙂
