{
    "$id": "https://www.fatzebra.com/schemas/payment-method.json",
    "type": "object",
    "definitions": {
        "PaymentMethod": {
            "type": "object",
            "oneOf": [
                {
                    "properties": {
                        "type": {
                            "const": "card"
                        },
                        "data": {
                            "type": "object",
                            "properties": {
                                "number": { "type": "string" },
                                "holder": { "type": "string" },
                                "expiryMonth": {
                                    "type": "string",
                                    "enum": ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]
                                },
                                "expiryYear": {
                                    "type": "string",
                                    "maxLength": 4
                                },
                                "cvv": { "type": "string" }
                            },
                            "required": ["number", "holder", "expiryMonth", "expiryYear", "cvv"]
                        }
                    },
                    "required": ["type", "data"]
                },
                {
                    "properties": {
                        "type": {
                            "const": "card_on_file"
                        },
                        "data": {
                            "type": "object",
                            "properties": {
                                "token": { "type": "string" }
                            },
                            "required": ["token"]
                        }
                    },
                    "required": ["type", "data"]
                }
            ]
        }
    }
}
