Set customer

The customer is the person who buy the ticket. These data are used to create the invoice and, if the activity does not require a custom participants info, the ticket.

A cart cannot be transformed into an order if the customer is not set.

To get all information required for your cart you need to call the endpoint

curl -X GET \
  https://api.musement.com/api/v3/carts/[CART_UUID]/customer/schema \
  -H 'Accept-Language: it' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json'

The response will be a json schema with all required information to create a form.

❗️

Always prepend "TEST" to your test orders

When testing in any environment, please remember adding "TEST" word before customer first name and last name.

A sample response is like

{
  "type": "object",
  "title": "cart_customer_guest",
  "properties": {
    "firstname": {
      "type": "string",
      "title": "firstname",
      "propertyOrder": 1
    },
    "lastname": {
      "type": "string",
      "title": "Cognome",
      "propertyOrder": 2
    },
    "email": {
      "type": "string",
      "title": "email",
      "format": "email",
      "propertyOrder": 3
    },
    "musement_newsletter": {
      "enum": [
        "NO",
        "YES"
      ],
      "enum_titles": [
        "NO",
        "YES"
      ],
      "type": "string",
      "title": "musement_newsletter",
      "propertyOrder": 4
    },
    "allow_profiling": {
      "enum": [
        "YES",
        "NO"
      ],
      "enum_titles": [
        "YES",
        "NO"
      ],
      "type": "string",
      "title": "allow_profiling",
      "propertyOrder": 5
    },
    "thirdparty_newsletter": {
      "enum": [
        "YES",
        "NO"
      ],
      "enum_titles": [
        "YES",
        "NO"
      ],
      "type": "string",
      "title": "thirdparty_newsletter",
      "propertyOrder": 6
    },
    "events_related_newsletter": {
      "enum": [
        "YES",
        "NO"
      ],
      "enum_titles": [
        "YES",
        "NO"
      ],
      "type": "string",
      "title": "events_related_newsletter",
      "propertyOrder": 7
    },
    "city": {
      "type": "string",
      "title": "city",
      "propertyOrder": 8
    },
    "address": {
      "type": "string",
      "title": "address",
      "propertyOrder": 9
    },
    "zipcode": {
      "type": "string",
      "title": "zipcode",
      "propertyOrder": 10
    },
    "tax_id": {
      "type": "string",
      "title": "tax_id",
      "propertyOrder": 11
    },
    "extra_customer_data": {
      "title": "extra_customer_data",
      "type": "object",
      "properties": {
        "11eeb25c-2046-11e7-9cc9-06a7e332783f": {
          "title": "11eeb25c-2046-11e7-9cc9-06a7e332783f",
          "type": "object",
          "properties": {
            "please_provide_your_cell_phone_number": {
              "type": "number",
              "title": "Please provide your cell phone number",
              "propertyOrder": 1
            },
            "your_weight": {
              "type": "number",
              "title": "Please insert your weight",
              "propertyOrder": 2
            }
          },
          "required": [
            "please_provide_your_cell_phone_number"
          ],
          "propertyOrder": 1
        }
      },
      "required": [
        "11eeb25c-2046-11e7-9cc9-06a7e332783f"
      ],
      "propertyOrder": 12
    }
  },
  "required": [
    "firstname",
    "lastname",
    "email",
    "musement_newsletter",
    "allow_profiling",
    "thirdparty_newsletter",
    "events_related_newsletter",
    "city",
    "address",
    "zipcode",
    "tax_id",
    "extra_customer_data"
  ]
}

Using these data you can create your form and validate it before send it.

👍

Be aware of JSON Schema

For a tool that create a form from a json schema you can try https://mozilla-services.github.io/react-jsonschema-form/ . Paste the json schema returned by Musement's API on the "JSONSchema" text area and see how the form appear on the right.

An interesting read about json schema, forms and API is https://blog.apisyouwonthate.com/the-many-amazing-uses-of-json-schema-client-side-validation-c78a11fbde45

📘

About Privacy field

You must specify a YES/NO value for
"musement_newsletter" -> to subscribe the customer to Musement newsletter.
"thirdparty_newsletter" -> to let the customer receive promotional offers from 3rd parties.
"events_related_newsletter" -> to subscribe the customer to 3rd parties newsletter related to the event.
"allow_profiling" -> to allow Musement to profile user data for future use.

By default, the last one is set to no.

Extra customer data

Some activity require extra data to be purchased.

As you probably noted in the section above there is a section called extra_customer_data. This section might or might not be present depending on the activities presents in the cart.

[..]
{
  "extra_customer_data": {
    "title": "extra_customer_data",
    "type": "object",
    "properties": {
      "11eeb25c-2046-11e7-9cc9-06a7e332783f": {
        "title": "11eeb25c-2046-11e7-9cc9-06a7e332783f",
        "type": "object",
        "properties": {
          "please_provide_your_cell_phone_number": {
            "type": "number",
            "title": "Please provide your cell phone number",
            "propertyOrder": 1
          },
          "your_weight": {
            "type": "number",
            "title": "Please insert your weight",
            "propertyOrder": 2
          }
        },
        "required": [
          "please_provide_your_cell_phone_number"
        ],
        "propertyOrder": 1
      }
    },
    "required": [
      "11eeb25c-2046-11e7-9cc9-06a7e332783f"
    ],
    "propertyOrder": 12
  }
}
[..]

This section specify all extra customer data required. It's up to the client application if ask for these data in the same page as the standard one.

One important thing to note is that these data refer to the customer and do not depend on the quantity purchased.

A sample request looks like:

curl -X PUT \
  https://api.musement.com/api/v3/carts/[CART_UUID]/customer \
  -H 'Accept-Language: it' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
  "firstname": "Anna",
  "lastname": "Verdi ",
  "email": "[email protected]",
  "extra_customer_data": {
    "11eeb25c-2046-11e7-9cc9-06a7e332783f": {
      "please_provide_your_cell_phone_number": "123456789"
    }
  }
}'