package Ġe loc . flow . loc Ċ Ċ import Ġco . parallel universe . fib ers . Suspend able Ċ import Ġe loc . contract . Bill Of L ading Contract Ċ import Ġe loc . contract . Letter Of Credit Contract Ċ import Ġe loc . flow .* Ċ import Ġe loc . state . Bill Of L ading State Ċ import Ġe loc . state . Letter Of Credit State Ċ import Ġe loc . state . Letter Of Credit Status Ċ import Ġnet . cord a . core . contracts . Amount Ċ import Ġnet . cord a . core . flows .* Ċ import Ġnet . cord a . core . node . services . query By Ċ import Ġnet . cord a . core . transactions . Signed Transaction Ċ import Ġnet . cord a . core . transactions . Transaction Builder Ċ import Ġnet . cord a . core . utilities . Progress Tracker Ċ import Ġnet . cord a . finance . contracts . asset . Cash Ċ import Ġjava . time . Duration Ċ import Ġjava . time . Instant Ċ Ċ @ Initi ating Flow Ċ @ Start able By RPC Ċ class ĠAd vis ory Payment Flow ( val Ġloc Id : ĠString ) Ġ: ĠFlow Logic < Signed Transaction >() Ġ{ ĊĊĠĠĠ Ġoverride Ġval Ġprogress Tracker Ġ= ĠProgress Tracker ( GET TING _ NOT ARY , ĠGENER ATING _ TRANSACTION , ĠVERIFY ING _ TRANSACTION , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSIGN ING _ TRANSACTION , ĠFIN AL ISING _ TRANSACTION ) ĊĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall (): ĠSigned Transaction Ġ{ ĊĠĠĠĠĠĠĠ Ġprogress Tracker . current Step Ġ= ĠGET TING _ NOT ARY ĊĠĠĠĠĠĠĠ Ġval Ġnot ary Ġ= Ġservice Hub . network Map Cache . not ary Id entities . first () ĊĊĠĠĠĠĠĠĠ Ġprogress Tracker . current Step Ġ= ĠGENER ATING _ TRANSACTION ĊĠĠĠĠĠĠĠ Ġval Ġloc States Ġ= Ġservice Hub . vault Service . query By < Letter Of Credit State >(). states . filter Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . state . data . status Ġ!= ĠLetter Of Credit Status . TERMIN ATED Ġ&& Ġit . state . data . props . letter Of Credit ID Ġ== Ġloc Id ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġif Ġ( loc States . isEmpty ()) Ġthrow ĠException (" Ad vis ing Ġbank Ġcould Ġnot Ġbe Ġpaid . ĠLetter Ġof Ġcredit Ġstate Ġwith ĠID Ġ$ loc Id Ġnot Ġfound .") ĊĠĠĠĠĠĠĠ Ġif Ġ( loc States . size Ġ> Ġ 1 ) Ġthrow ĠException (" Se veral Ġletter Ġof Ġcredit Ġstates Ġwith ĠID Ġ$ loc Id Ġfound .") ĊĠĠĠĠĠĠĠ Ġval Ġloc State Ġ= Ġloc States . single () ĊĊĠĠĠĠĠĠĠ Ġval Ġbol States Ġ= Ġservice Hub . vault Service . query By < Bill Of L ading State >(). states . filter Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . state . data . props . bill Of L ading ID Ġ== Ġloc Id ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġif Ġ( bol States . isEmpty ()) Ġthrow ĠException (" Ad vis ing Ġbank Ġcould Ġnot Ġbe Ġpaid . ĠBill Ġof Ġl ading Ġhas Ġnot Ġbeen Ġcreated .") ĊĠĠĠĠĠĠĠ Ġif Ġ( bol States . size Ġ> Ġ 1 ) Ġthrow ĠException (" Se veral Ġbill Ġof Ġl ading Ġstates Ġwith ĠID Ġ$ loc Id Ġfound .") ĊĠĠĠĠĠĠĠ Ġval Ġbol State Ġ= Ġbol States . single () ĊĊĠĠĠĠĠĠĠ Ġval Ġpay ee Ġ= Ġloc State . state . data . advis ing Bank ĊĊĠĠĠĠĠĠĠ Ġval Ġoutput State Ġ= Ġloc State . state . data . advisory Paid () ĊĠĠĠĠĠĠĠ Ġval Ġoutput State B ol Ġ= Ġbol State . state . data . copy ( owner Ġ= Ġour Identity , Ġtimestamp Ġ= ĠInstant . now ()) ĊĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠTransaction Builder ( not ary Ġ= Ġnot ary ) ĊĠĠĠĠĠĠĠ Ġbuilder . setTime Window ( Instant . now (), ĠDuration . of Seconds ( 6 0 )) ĊĊĠĠĠĠĠĠĠ Ġval Ġ(_, Ġsigning Keys ) Ġ= ĠCash . generate S pend ( service Hub , Ġbuilder , Ġloc State . state . data . props . amount , Ġpay ee ) ĊĊĠĠĠĠĠĠĠ Ġbuilder . add Input State ( loc State ) ĊĠĠĠĠĠĠĠ Ġbuilder . add Input State ( bol State ) ĊĠĠĠĠĠĠĠ Ġbuilder . add Output State ( output State , ĠLetter Of Credit Contract . CONTRACT _ ID ) ĊĠĠĠĠĠĠĠ Ġbuilder . add Output State ( output State B ol , ĠBill Of L ading Contract . CONTRACT _ ID ) ĊĠĠĠĠĠĠĠ Ġbuilder . add Command ( Letter Of Credit Contract . Commands . Pay Ad vis ing Bank (), ĠlistOf ( our Identity . own ing Key )) ĊĠĠĠĠĠĠĠ Ġbuilder . add Command ( Bill Of L ading Contract . Commands . Transfer (), Ġour Identity . own ing Key ) ĊĊĠĠĠĠĠĠĠ Ġprogress Tracker . current Step Ġ= ĠVERIFY ING _ TRANSACTION ĊĠĠĠĠĠĠĠ Ġbuilder . verify ( service Hub ) ĊĊĠĠĠĠĠĠĠ Ġprogress Tracker . current Step Ġ= ĠSIGN ING _ TRANSACTION ĊĠĠĠĠĠĠĠ Ġval Ġst x Ġ= Ġservice Hub . sign Initial Transaction ( builder , Ġsigning Keys Ġ+ Ġour Identity . own ing Key ) ĊĊĠĠĠĠĠĠĠ Ġprogress Tracker . current Step Ġ= ĠFIN AL ISING _ TRANSACTION ĊĠĠĠĠĠĠĠ Ġreturn Ġsub Flow ( Final ity Flow ( st x )) ĊĠĠĠ Ġ} Ċ }