<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0.0">
    <!--=====================================================================-->
    <!--                        Schema Management                            -->
    <!--=====================================================================-->
    <!--                             IMPORTS                                 -->
    <!--                          DOCUMENTATION                              -->
    <xsd:annotation>
        <xsd:documentation xml:lang="en"/>
        <xsd:documentation>
            <name>Refund Interface</name>
            <revision version="1.0.0">
                <date>2023-MAY-23</date>
            </revision>
        </xsd:documentation>
    </xsd:annotation>
    <!--                             INCLUDE                                 -->
    <!--                            REDEFINE                                 -->
    <!--=====================================================================-->
    <!--                    Model-Building Components                        -->
    <!--=====================================================================-->
    <!--                            NOTATIONS                                -->
    <!--                           SIMPLE TYPES                              -->
    <xsd:simpleType name="ModeSimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:enumeration value="direct"/>
            <xsd:enumeration value="batch"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:simpleType name="BatchIdentifierSimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:minLength value="22"/>
            <xsd:maxLength value="150"/>
            <xsd:pattern value="[A-Z]{1,4}-[A-Z,0-9]{1,32}-[A-Z,0-9]{1,32}-([A-Z]{1,32}-){0,2}[0-9]{17}"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:simpleType name="IdentifierSimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:minLength value="1"/>
            <xsd:maxLength value="32"/>
            <xsd:pattern value="[0-9a-zA-Z]{1,32}"/>
        </xsd:restriction>
    </xsd:simpleType>
   
    <xsd:simpleType name="VersionSimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:pattern value="[0-9].[0-9]"/>
        </xsd:restriction>
    </xsd:simpleType>
        
    <xsd:simpleType name="DateSimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:minLength value="10"/>
            <xsd:maxLength value="10"/>
            <xsd:pattern value="[0-9]{4}-[0-9]{2}-[0-9]{2}"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:simpleType name="DateTimeSimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:minLength value="24"/>
            <xsd:maxLength value="24"/>
            <xsd:pattern value="[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}Z"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:simpleType name="MessageCountSimpleType">
        <xsd:restriction base="xsd:nonNegativeInteger">
            <xsd:minInclusive value="0"/>
            <xsd:maxInclusive value="3000"/>
        </xsd:restriction>
    </xsd:simpleType>
            
    <xsd:simpleType name="DebtorReferenceSimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:minLength value="1"/>
            <xsd:maxLength value="35"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:simpleType name="TokenLength128SimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:maxLength value="128"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="TokenLength256SimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:maxLength value="256"/>
        </xsd:restriction>
    </xsd:simpleType>

    
    <xsd:simpleType name="TokenLength200SimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:maxLength value="200"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:simpleType name="TokenLength64SimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:maxLength value="64"/>
        </xsd:restriction>
    </xsd:simpleType>

        
   <xsd:simpleType name="TokenLength10SimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:maxLength value="10"/>
        </xsd:restriction>
    </xsd:simpleType>
 
    <xsd:simpleType name="EntranceCodeSimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:minLength value="1"/>
            <xsd:maxLength value="40"/>
            <xsd:pattern value="[0-9a-zA-Z]{1,40}"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:simpleType name="ErrorCodeSimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:pattern value="[A-Z]{2}[0-9]{4}"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:simpleType name="TransactionIDType">
        <xsd:restriction base="xsd:token">
            <xsd:pattern value="[0-9a-zA-Z]{1,64}"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:simpleType name="DescriptionSimpleType">
        <xsd:restriction base="xsd:token">
	        <xsd:pattern value="[-0-9a-zA-ZàáâäæãåāçćčèéêëēėęîïíīįìłñńôöòóœøōõßśšûüùúūÿžźżÀÁÂÄÆÃÅĀÇĆČÈÉÊËĒĖĘÎÏÍĪĮÌŁÑŃÔÖÒÓŒØŌÕŚŠÛÜÙÚŪŸŽŹŻ€ ()+,.@&amp;=%&quot;&apos;/:;?$]{1,35}"/>
        </xsd:restriction>
    </xsd:simpleType>
    
    <xsd:simpleType name="AmountSimpleType">
        <xsd:restriction base="xsd:decimal">
            <xsd:minInclusive value="0.01"/>
            <xsd:maxInclusive value="50000.00"/>
            <xsd:pattern value="\d{1,9}\.\d{2}|\d{0}"/>
        </xsd:restriction>
    </xsd:simpleType>


    <!--                          COMPLEX TYPES                              -->
 
    <!--                          ROOT ELEMENT TYPE                          -->
    <xsd:complexType name="RefundInterfaceType">
        <xsd:choice maxOccurs="unbounded" minOccurs="0">
            <xsd:element name="RefundTransactionRequest"  type="RefundTransactionRequestType" maxOccurs="1"/>
            <xsd:element name="RefundTransactionResponse" type="RefundTransactionResponseType" maxOccurs="1"/>
            <xsd:element name="RefundErrorResponse"       type="RefundErrorResponseType" minOccurs="0" maxOccurs="1"/>
        </xsd:choice>
        <xsd:attributeGroup ref="HeaderAttributes"/>
    </xsd:complexType>
    
    <!--                      COMPLEX TYPES DESCRIBING MAIN DOCUMENTS TYPES  -->
     <xsd:complexType name="RefundTransactionRequestType">
        <xsd:all>
            <xsd:element name="BluemTransactionID" type="TransactionIDType"/>
			<xsd:element name="DebtorReference" type="DebtorReferenceSimpleType" minOccurs="0"/>
            <xsd:element name="Description" type="DescriptionSimpleType"/>
            <xsd:element name="RefundAmount" type="AmountSimpleType"/>
            <xsd:element name="ProcessDateTime" type="DateTimeSimpleType"/>

        </xsd:all>
        <xsd:attributeGroup ref="RequestAttributes"/>
    </xsd:complexType>
        
            
    <xsd:complexType name="RefundTransactionResponseType">
       <xsd:all>
            <xsd:element name="RefundStatus" type="RefundStatustSimpleType"/>
             <xsd:element name="Error" type="ErrorComplexType" minOccurs="0"/>
            <xsd:element name="BluemTransactionID" type="TransactionIDType"/>
			<xsd:element name="DebtorReference" type="DebtorReferenceSimpleType" minOccurs="0"/>
            <xsd:element name="RequestedRefundAmount" type="AmountSimpleType"/>
            <xsd:element name="RefundedAmount" type="AmountSimpleType" minOccurs="0"/>
       </xsd:all>
        <xsd:attributeGroup ref="RequestAttributes"/>
    </xsd:complexType>
    
    
    <!-- BELOW IS TEMP  -->
    <xsd:complexType name="RefundErrorResponseType">
        <xsd:sequence>
            <xsd:element name="Error" type="ErrorComplexType" maxOccurs="1"/>
        </xsd:sequence>
    </xsd:complexType>
    
    
    
    <xsd:simpleType name="RefundStatustSimpleType">
        <xsd:restriction base="xsd:token">
            <xsd:enumeration value="ok"/>
            <xsd:enumeration value="error"/>
        </xsd:restriction>
    </xsd:simpleType>

             
    <!--                      OTHER COMPLEX TYPES                            -->    
    <xsd:complexType name="ErrorComplexType">
        <xsd:sequence>
            <xsd:element name="ErrorCode" type="ErrorCodeSimpleType"/>
            <xsd:element name="ErrorMessage" type="TokenLength128SimpleType"/>
            <xsd:element name="ErrorDetail" type="TokenLength256SimpleType" minOccurs="0"/>
            <xsd:element name="Object" type="TokenLength256SimpleType" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>
             
      
    <!--                        ATTRIBUTE GROUPS                             -->
    <xsd:attributeGroup name="HeaderAttributes">
        <xsd:attribute name="mode"           type="ModeSimpleType" use="required"/>
        <xsd:attribute name="batchID"        type="BatchIdentifierSimpleType"/>
        <xsd:attribute name="senderID"       type="IdentifierSimpleType" use="required"/>
        <xsd:attribute name="version"        type="VersionSimpleType" default="1.0"/>
        <xsd:attribute name="createDateTime" type="DateTimeSimpleType" use="required"/>
        <xsd:attribute name="messageCount"   type="MessageCountSimpleType" use="required"/>
        <xsd:attribute name="type" use="required">
            <xsd:simpleType>
                <xsd:restriction base="xsd:token">
                    <xsd:enumeration value="TransactionRequest"/>
                    <xsd:enumeration value="TransactionResponse"/>
                    <xsd:enumeration value="ErrorResponse"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
    </xsd:attributeGroup>
    
    <xsd:attributeGroup name="RequestAttributes">
    	<xsd:attribute name="entranceCode" type="EntranceCodeSimpleType"/>
    </xsd:attributeGroup>
    <!--                            ATTRIBUTES                               -->
    
    <!--                              GROUPS                                 -->
    
    <!--                             ELEMENTS                                -->
    <xsd:element name="RefundInterface" type="RefundInterfaceType"/>
    
</xsd:schema>