@prefix op:    <https://openpay.transaction.science/vocab/v1#> .
@prefix sh:    <http://www.w3.org/ns/shacl#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .

# OpenPay v1 SHACL shapes — validates Money, Receipt, Refund, and
# PaymentMethod wire forms before they cross a rail-driver
# boundary. Catches malformed amounts, wrong-currency dispatches,
# and lifecycle drift early.

op:MoneyShape a sh:NodeShape ;
    sh:targetClass op:Money ;
    sh:property [ sh:path op:amountMinorUnits ; sh:datatype xsd:integer ; sh:minCount 1 ; sh:maxCount 1 ] ;
    sh:property [ sh:path op:currency         ; sh:datatype xsd:string  ; sh:minCount 1 ; sh:maxCount 1 ;
                  sh:pattern "^[A-Z]{3}$" ] .

op:ReceiptShape a sh:NodeShape ;
    sh:targetClass op:Receipt ;
    sh:property [ sh:path op:method        ; sh:nodeKind sh:IRI ; sh:minCount 1 ; sh:maxCount 1 ;
                  sh:in ( op:Card op:A2A op:Stablecoin op:Wallet op:EMV ) ] ;
    sh:property [ sh:path op:rail          ; sh:nodeKind sh:IRI ; sh:maxCount 1 ;
                  sh:in ( op:FedNow op:PIX op:SEPAInstant op:USDC op:USDT ) ] ;
    sh:property [ sh:path op:status        ; sh:nodeKind sh:IRI ; sh:minCount 1 ; sh:maxCount 1 ;
                  sh:in ( op:Authorized op:Captured op:Settled op:Refunded op:Voided op:Disputed op:Failed ) ] ;
    sh:property [ sh:path op:idempotencyKey ; sh:datatype xsd:string   ; sh:minCount 1 ; sh:maxCount 1 ] ;
    sh:property [ sh:path op:driverId      ; sh:datatype xsd:string    ; sh:maxCount 1 ] ;
    sh:property [ sh:path op:authorizedAt  ; sh:datatype xsd:dateTime  ; sh:maxCount 1 ] ;
    sh:property [ sh:path op:capturedAt    ; sh:datatype xsd:dateTime  ; sh:maxCount 1 ] ;
    sh:property [ sh:path op:settledAt     ; sh:datatype xsd:dateTime  ; sh:maxCount 1 ] .

op:RefundShape a sh:NodeShape ;
    sh:targetClass op:Refund ;
    sh:property [ sh:path op:refundedAt ; sh:datatype xsd:dateTime ; sh:minCount 1 ; sh:maxCount 1 ] .

# Card payment-method subshape — REQUIRES a card scheme.
op:CardShape a sh:NodeShape ;
    sh:targetClass op:Card ;
    sh:property [ sh:path op:scheme    ; sh:nodeKind sh:IRI       ; sh:minCount 1 ; sh:maxCount 1 ;
                  sh:in ( op:Visa op:Mastercard op:Amex op:Discover ) ] ;
    sh:property [ sh:path op:vaultRef  ; sh:datatype xsd:string   ; sh:minCount 1 ; sh:maxCount 1 ] .
