{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:hsimc:miacto:provider-profile:1.0",
  "title": "Miacto provider payment and resource profile — C0-002",
  "description": "Configuration contract, not a running payment integration. No secret values or private bank instructions belong in this object. Draft exports cannot enable channels.",
  "type": "object",
  "properties": {
    "schema": {
      "const": "miacto.provider-profile"
    },
    "schema_version": {
      "const": "1.0"
    },
    "configuration_status": {
      "enum": [
        "draft",
        "review",
        "active",
        "suspended"
      ]
    },
    "provider": {
      "type": "object",
      "properties": {
        "party_ref": {
          "type": "string",
          "minLength": 1
        },
        "display_name": {
          "type": "string",
          "minLength": 1
        },
        "registration_region": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[A-Z]{2}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "public_contact_url": {
          "anyOf": [
            {
              "type": "string",
              "format": "uri",
              "pattern": "^https://"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "party_ref",
        "display_name",
        "registration_region",
        "public_contact_url"
      ],
      "additionalProperties": false
    },
    "resources": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "resource_ref": {
            "type": "string",
            "minLength": 1
          },
          "resource_version": {
            "type": "string",
            "minLength": 1
          },
          "service": {
            "enum": [
              "store",
              "verify",
              "execute"
            ]
          },
          "resource_type": {
            "enum": [
              "digital",
              "physical",
              "mixed"
            ]
          },
          "entry_url": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri",
                "pattern": "^https://"
              },
              {
                "type": "null"
              }
            ]
          },
          "availability": {
            "enum": [
              "unverified",
              "quote_required",
              "available",
              "unavailable"
            ]
          },
          "evidence_ref": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "resource_ref",
          "resource_version",
          "service",
          "resource_type",
          "entry_url",
          "availability",
          "evidence_ref"
        ],
        "additionalProperties": false
      }
    },
    "payment_channels": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "channel_id": {
            "type": "string",
            "minLength": 1
          },
          "kind": {
            "enum": [
              "stripe_checkout",
              "stripe_payment_link",
              "bank_transfer",
              "bank_api",
              "digital_currency_adapter"
            ]
          },
          "account_holder_party_ref": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "enum": [
              "draft",
              "test",
              "live"
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "activation_status": {
            "enum": [
              "draft",
              "review",
              "test_passed",
              "active",
              "suspended"
            ]
          },
          "regions": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Z]{2}$"
            }
          },
          "currencies_or_assets": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Z0-9]{3,12}$"
            }
          },
          "public_checkout_url": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri",
                "pattern": "^https://"
              },
              {
                "type": "null"
              }
            ]
          },
          "protected_configuration_ref": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "null"
              }
            ]
          },
          "credential_ref": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "null"
              }
            ]
          },
          "confirmation_method": {
            "enum": [
              "not_configured",
              "provider_webhook",
              "bank_api_verified",
              "authorized_reconciliation",
              "chain_adapter_verified"
            ]
          },
          "per_work_reference_required": {
            "const": true
          },
          "region_policy_ref": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "null"
              }
            ]
          },
          "digital_currency": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "network_id": {
                    "type": "string",
                    "minLength": 1
                  },
                  "asset_id": {
                    "type": "string",
                    "minLength": 1
                  },
                  "confirmation_rule_ref": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "network_id",
                  "asset_id",
                  "confirmation_rule_ref"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "channel_id",
          "kind",
          "account_holder_party_ref",
          "environment",
          "enabled",
          "activation_status",
          "regions",
          "currencies_or_assets",
          "public_checkout_url",
          "protected_configuration_ref",
          "credential_ref",
          "confirmation_method",
          "per_work_reference_required",
          "region_policy_ref",
          "digital_currency"
        ],
        "additionalProperties": false,
        "allOf": [
          {
            "if": {
              "properties": {
                "enabled": {
                  "const": true
                }
              }
            },
            "then": {
              "properties": {
                "activation_status": {
                  "const": "active"
                },
                "environment": {
                  "const": "live"
                },
                "region_policy_ref": {
                  "type": "string",
                  "minLength": 1
                },
                "regions": {
                  "minItems": 1
                },
                "currencies_or_assets": {
                  "minItems": 1
                },
                "confirmation_method": {
                  "not": {
                    "const": "not_configured"
                  }
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "enabled": {
                  "const": true
                },
                "kind": {
                  "enum": [
                    "stripe_checkout",
                    "stripe_payment_link"
                  ]
                }
              }
            },
            "then": {
              "anyOf": [
                {
                  "properties": {
                    "public_checkout_url": {
                      "type": "string",
                      "format": "uri",
                      "pattern": "^https://"
                    }
                  }
                },
                {
                  "properties": {
                    "protected_configuration_ref": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                }
              ]
            }
          },
          {
            "if": {
              "properties": {
                "enabled": {
                  "const": true
                },
                "kind": {
                  "enum": [
                    "bank_transfer",
                    "bank_api"
                  ]
                }
              }
            },
            "then": {
              "properties": {
                "protected_configuration_ref": {
                  "type": "string",
                  "minLength": 1
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "enabled": {
                  "const": true
                },
                "kind": {
                  "const": "digital_currency_adapter"
                }
              }
            },
            "then": {
              "properties": {
                "protected_configuration_ref": {
                  "type": "string",
                  "minLength": 1
                },
                "digital_currency": {
                  "type": "object"
                }
              }
            }
          }
        ]
      }
    },
    "settlement": {
      "type": "object",
      "properties": {
        "default_model": {
          "const": "hsimc_provider_bilateral"
        },
        "automatic_split_enabled": {
          "const": false
        },
        "direct_provider_route": {
          "enum": [
            "planned",
            "disabled"
          ]
        },
        "agreement_ref": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "default_model",
        "automatic_split_enabled",
        "direct_provider_route",
        "agreement_ref"
      ],
      "additionalProperties": false
    },
    "mcp": {
      "type": "object",
      "properties": {
        "target_protocol_version": {
          "const": "2026-07-28"
        },
        "endpoint": {
          "anyOf": [
            {
              "type": "string",
              "format": "uri",
              "pattern": "^https://"
            },
            {
              "type": "null"
            }
          ]
        },
        "integration_status": {
          "enum": [
            "not_connected",
            "testing",
            "verified"
          ]
        },
        "authorization_required_for_paid_actions": {
          "const": true
        },
        "explicit_work_reference_required": {
          "const": true
        }
      },
      "required": [
        "target_protocol_version",
        "endpoint",
        "integration_status",
        "authorization_required_for_paid_actions",
        "explicit_work_reference_required"
      ],
      "additionalProperties": false
    },
    "review": {
      "type": "object",
      "properties": {
        "owner_approved": {
          "type": "boolean"
        },
        "region_review_ref": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "integration_test_ref": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "owner_approved",
        "region_review_ref",
        "integration_test_ref"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "schema",
    "schema_version",
    "configuration_status",
    "provider",
    "resources",
    "payment_channels",
    "settlement",
    "mcp",
    "review"
  ],
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "configuration_status": {
            "not": {
              "const": "active"
            }
          }
        }
      },
      "then": {
        "properties": {
          "payment_channels": {
            "items": {
              "properties": {
                "enabled": {
                  "const": false
                }
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "configuration_status": {
            "const": "active"
          }
        }
      },
      "then": {
        "properties": {
          "review": {
            "properties": {
              "owner_approved": {
                "const": true
              },
              "region_review_ref": {
                "type": "string",
                "minLength": 1
              },
              "integration_test_ref": {
                "type": "string",
                "minLength": 1
              }
            }
          }
        }
      }
    }
  ]
}
