# Generation of source\_id with api endpoint

**URL:** <https://developer.squareup.com/forums/t/generation-of-source-id-with-api-endpoint/7273>\
**Category:** Questions\
**Created:** [October 13, 2022, 11:09pm UTC](https://developer.squareup.com/forums/t/generation-of-source-id-with-api-endpoint/7273 "2022-10-13T23:09:12Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ATECH](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@ATECH](https://developer.squareup.com/forums/u/ATECH)\
**Post date:** [October 13, 2022, 11:09pm UTC](https://developer.squareup.com/forums/t/generation-of-source-id-with-api-endpoint/7273/1 "2022-10-13T23:09:12Z")

</div>

How can I generate the source\_id of my card data with api endpoint? I want to use postman to call the api endpoint.

---

<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 13, 2022, 11:37pm UTC](https://developer.squareup.com/forums/t/generation-of-source-id-with-api-endpoint/7273/2 "2022-10-13T23:37:06Z")

</div>

You’ll need to use the [Web Payments SDK](https://developer.squareup.com/docs/web-payments/overview) to generate a `source_id`. Passing raw card data to an endpoint to generate a `source_id` isn’t available. 🙂

---

<div class="post-metadata">

**Author:** ![ATECH](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@ATECH](https://developer.squareup.com/forums/u/ATECH)\
**Post date:** [October 13, 2022, 11:41pm UTC](https://developer.squareup.com/forums/t/generation-of-source-id-with-api-endpoint/7273/3 "2022-10-13T23:41:16Z")

</div>

Thank you for your answer. I only make the API of backend of my server. So I do not use Web Form in my backend. You mean, Square is not provide the backend to generate source\_id of the card data. Right?

---

<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 13, 2022, 11:44pm UTC](https://developer.squareup.com/forums/t/generation-of-source-id-with-api-endpoint/7273/4 "2022-10-13T23:44:56Z")

</div>

Right, you’ll have to use the front end SDK to first to generate the `source_id`. There isn’t a backend way to generate the `source_id`. If your testing in sandbox we do have a test value `cnon:card-nonce-ok` that you can use for testing all the backend functions. 🙂

---

<div class="post-metadata">

**Author:** ![ATECH](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@ATECH](https://developer.squareup.com/forums/u/ATECH)\
**Post date:** [October 13, 2022, 11:48pm UTC](https://developer.squareup.com/forums/t/generation-of-source-id-with-api-endpoint/7273/5 "2022-10-13T23:48:06Z")

</div>

But how is the opencart Square module worked without your front end sdk?

---

<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 13, 2022, 11:51pm UTC](https://developer.squareup.com/forums/t/generation-of-source-id-with-api-endpoint/7273/6 "2022-10-13T23:51:36Z")

</div>

The form field that the customer puts the card information in is the Web Payment SDK form field. They use that to generate the `source_id` that’s then passed to the backend to make the server side `CreatePayment` call. 🙂

---

<div class="post-metadata">

**Author:** ![ATECH](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@ATECH](https://developer.squareup.com/forums/u/ATECH)\
**Post date:** [October 13, 2022, 11:53pm UTC](https://developer.squareup.com/forums/t/generation-of-source-id-with-api-endpoint/7273/7 "2022-10-13T23:53:03Z")

</div>

hmmm, looks like you didn’t see the Square opencart module. Ok, thanks for your answer.

---

<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 14, 2022, 12:10am UTC](https://developer.squareup.com/forums/t/generation-of-source-id-with-api-endpoint/7273/8 "2022-10-14T00:10:46Z")

</div>

Where are you looking in the module? I see the JS library link to the Web Payments SDK in the `square_3.4_2c414bc09c/upload/catalog/controller/extension/payment/squareup.php` 🙂

---

<div class="post-metadata">

**Author:** ![ATECH](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@ATECH](https://developer.squareup.com/forums/u/ATECH)\
**Post date:** [October 14, 2022, 12:37am UTC](https://developer.squareup.com/forums/t/generation-of-source-id-with-api-endpoint/7273/9 "2022-10-14T00:37:23Z")

</div>

At opencart plugin, how to use js library in php backend?

---

<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 14, 2022, 4:08pm UTC](https://developer.squareup.com/forums/t/generation-of-source-id-with-api-endpoint/7273/10 "2022-10-14T16:08:52Z")

</div>

For specific questions about the Opencart plugin you’ll want to reach out to them directly since they’re the ones that built the integration. As for how to use the Web Payments SDK with a PHP backend we have this [example](https://github.com/square/connect-api-examples/tree/master/connect-examples/v2/php_payment) that you can use. 🙂

---

<div class="post-metadata">

**Author:** ![maint3839](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@maint3839](https://developer.squareup.com/forums/u/maint3839)\
**Post date:** [May 12, 2023, 6:28pm UTC](https://developer.squareup.com/forums/t/generation-of-source-id-with-api-endpoint/7273/11 "2023-05-12T18:28:30Z")

</div>

I am having the same issue.

I can’t find the way to get the source\_id with the card details like card number, expiry, cvv, postal code. What is the endpoint to get the source\_id from card details?

How can I get the source\_id?  
I searched all documents and examples on Square website but it keeps going back to Bryan’s answer that “The SDK produces a secure one-time use payment token that your application web client sends to your backend”. OK OK.  
Where and How SDK produces that TOKEN??

I am using Django as my backend. I made it work to process payment with dummy souce\_id:cnon:card-nonce-ok

But I need to get REAL source\_id not ```cnon:card-nonce-ok"

---

<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:** [May 12, 2023, 6:57pm UTC](https://developer.squareup.com/forums/t/generation-of-source-id-with-api-endpoint/7273/12 "2023-05-12T18:57:09Z")

</div>

You have to use our client side [Web Payments SDK](https://developer.squareup.com/docs/web-payments/overview) to generate the `source_id` that’s used to pass to the `CreatePayment` call. There isn’t an endpoint you can call that will generate a `source_id`. 🙂
