{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ucp.vipps.no/ucp/2026-04-08/schemas/wallet_payment_credential.json",
  "title": "Vipps Wallet Payment Credential",
  "description": "Credential schema for the no.vipps.ucp.payment_handler payment handler. Supports MSISDN and TOKEN credential types.",
  "type": "object",
  "required": ["type", "value"],
  "properties": {
    "type": {
      "enum": ["MSISDN", "TOKEN"],
      "description": "The credential type used for wallet payments. MSISDN uses phone number identification. TOKEN uses an encoded customer token."
    },
    "value": {
      "type": "string",
      "description": "The credential value. For MSISDN: phone number in MSISDN format (digits only with country code, no leading zeros or plus sign, e.g., 4712345678). For TOKEN: an encoded customer token string obtained from authenticated sessions."
    }
  },
  "allOf": [
    {
      "if": { "properties": { "type": { "const": "MSISDN" } } },
      "then": {
        "properties": {
          "value": {
            "pattern": "^\\d{9,15}$",
            "minLength": 9,
            "maxLength": 15,
            "description": "The phone number in MSISDN format: digits only with country code and subscriber number, no leading zeros or plus sign. Example: 4712345678 for Norwegian number +47 12 34 56 78."
          }
        }
      }
    },
    {
      "if": { "properties": { "type": { "const": "TOKEN" } } },
      "then": {
        "properties": {
          "value": {
            "minLength": 1,
            "description": "An encoded customer token string. This token is obtained from authenticated user sessions and maps to the customerToken field in the Vipps ePayment API."
          }
        }
      }
    }
  ]
}
