@startuml xinvoice_sequence

actor Requestor as Requestor
actor Payer as Payer
participant "xInvoice Enabled App" as xInvoiceApp
participant "xInvoice App Backend" as xInvoiceBackend

Requestor -> xInvoiceApp: Create Wallet

group Payment Request Creation
xInvoiceApp -> "XRP Ledger": Create Wallet
note left: the app could be a mobile\napp like xumm or a web app\nlike xurlpay.org
Requestor -> xInvoiceApp: Enter Payment\nRequest Details
xInvoiceApp -> xInvoiceBackend: Generate xInvoice
xInvoiceApp -> xInvoiceBackend: Create Payload
xInvoiceApp -> xInvoiceBackend: Sign Payload
xInvoiceApp -> xInvoiceBackend: Create xInvoice and\nSave Request State\nas "PENDING"
xInvoiceBackend -> xInvoiceApp: Return xInvoice
xInvoiceApp -> Requestor: Return xInvoice
end

group Payment
Requestor -> "Payer": Sends xInvoice
Payer -> xInvoiceApp: Scans xInvoice
note left: the app could be a mobile\napp like xumm or a web app\nlike xurlpay.org

xInvoiceApp -> "XRP Ledger": Verify signature of \nxInvoice using\naccount public key
xInvoiceApp -> "XRP Ledger": Pay Invoice
end

group Backend Event Listener
xInvoiceBackend -> "XRP Ledger": Listen for\n"PENDING" xInvoice\nto be paid
xInvoiceBackend -> "xInvoice App Backend": Save xInvoice\nstate as "PAID"
end


@enduml