Python Checkout API Custom Fields

Hello,

I am working on a Python Checkout API and would like to include a custom field named user_id with the value of the customer’s primary key in the database.

Here is what I have that works

  "checkout_options": {
      "custom_fields": [
        {
          "title": str(current_user.id)
        }
      ],

However, I want the field name to be user_id not title. When I try to rename “title” to “user_id” it gives an error and fails.

I would like to return this user_id on a webhook to complete the transaction on my backend.

Thanks

MAB

:wave: 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:

Additional Documentation

Charge a Card on File
Integrate Customer Profiles with Other Services
Use Custom Attributes for Merchants

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.

The field name will be the what you fill in for the title. The title is what we call it on the API side. :slightly_smiling_face:

Hello Bryan,

Thank you for your response. I understand that the “title” should be a placeholder for the custom user key of the key:value pair.

The code that is generated by the Create Payment Link API explorer works as below.

      "custom_fields": [
        {
          "title": str(current_user.id)
        }

However, when I substitute my key/variable name it does not work. I would like the key:value pair to be …

      "custom_fields": [
        {
          "user_id": str(current_user.id)
        }

The field title shouldn’t be replaced. The title is the name of the custom field which you then set as user_id. For example:

"custom_fields": [
        {
          "title": str(current_user.id)
        }

When you do the above you won’t see title in the checkout. The customer will see the custom field and see user_id. :slightly_smiling_face: