purchase-flow.md

November 13, 2025 ยท View on GitHub

Flow option 1: With offers, without pre-sales, without 2-phase purchase

stateDiagram-v2
    DIRECTION LR
    [*] --> OFFERED
    OFFERED --> CONFIRMED : purchase-offer
    CONFIRMED --> ROLLBACK : rollback-purchase
staterelend-statehrefremarks
OFFEREDpurchase-offerCONFIRMEDPOST /processes/purchase-offers/executionwhen working with offers that can be bought directly
CONFIRMEDrollback-purchaseROLLBACKPOST /processes/rollback-purchase/executiondirect purchase, but with a time window to rollback the purchase

Example link collection to purchase an offer, containing an example link in status 'OFFERED'

[ 
    { "rel": "purchase-offer", 
      "href": "https://bike.org/tomp/v2/processes/purchase-offers/execution", 
      "body": { "inputs": { "offer": "2581dd23-460d-4df0-b8cf-fb2c97e17a40" } },
      "method": "POST",
      "type": "application/geo+json"
    }
]

Of course, in the link collection could contain of course a link to show the details, referring to the /collections/offers/items.

Example link collection to rollback a purchase, containing an example link in status 'CONFIRMED'

[ 
    { "rel": "rollback-purchase", 
      "href": "https://bike.org/tomp/v2/processes/rollback-purchase/execution", 
      "body": { "inputs": { "package": "2581dd23-460d-4df0-b8cf-fb2c97e17a40" } },
      "method": "POST",
      "type": "application/geo+json"
    }
]

Flow option 2: With offers, without pre-sales, 2-phase purchase

stateDiagram-v2
    DIRECTION LR
    [*] --> OFFERED
    OFFERED --> PENDING : purchase-offer
    PENDING --> CONFIRMED : confirm-purchase
    PENDING --> ROLLBACK : rollback-purchase
    PENDING --> EXPIRED : timeout, <br>mandatory confirm link
    PENDING --> CONFIRMED : timeout, <br>optional confirm link
staterelend-statehrefremarks
OFFEREDpurchase-offerPENDINGPOST /processes/purchase-offers/executionwhen working with offers that can be bought
PENDINGconfirm-purchaseCONFIRMEDPOST /processes/confirm-purchase/executionto confirm
PENDINGrollback-purchaseROLLBACKPOST /processes/rollback-purchase/executionto undo the purchase before the expiry time is reached
PENDINGEXPIREDtimeout, not confirmed. Only when there is a mandatory confirm-link
PENDINGCONFIRMEDautomatically, when there is no confirm-link or an optional one. There should be send a notification (MP Module)

Flow option 3: Pre-sales applies (combined with option 1 or 2)

stateDiagram-v2
    DIRECTION LR
    [*] --> OFFERED
    OFFERED --> OFFERED : pre sales operation
    OFFERED --> RELEASED : release offer
    OFFERED --> CONFIRMED : purchase package<br>continue flow 1
    OFFERED --> PENDING : purchase package<br>continue flow 2
    OFFERED --> EXPIRED : timeout

Note The 'purchase-offers' endpoint should not anymore applicable when you apply the 'pre-sales' module.

staterelend-statehrefremarks
OFFEREDselect-offersOFFEREDPOST /processes/select-offers/executionto bundle offers into a package, claims resources
update-travellerOFFEREDPOST /processes/update-traveller/execution
update-travel-specificationOFFEREDPOST /processes/update-travel-specification/executionstart & end location & time
assign-assetOFFEREDPOST /processes/assign-asset/executionbikes, seats
assign-ancillaryOFFEREDPOST /processes/assign-ancillary/execution
remove-offerOFFEREDPOST /processes/remove-offer/execution
OFFEREDrelease-packageRELEASEDPOST /processes/release-package/executionto release the claimed resources of the package
OFFEREDpurchase-packageCONFIRMEDPOST /processes/purchase-package/executionwhen working with packages, containing offers
OFFEREDpurchase-packagePENDINGPOST /processes/purchase-package/executionwhen working with packages, containing offers, 2 phase purchase
OFFEREDEXPIREDtimeout, not purchased before expiry time

Flow option 4: direct purchase of a product

stateDiagram-v2
    DIRECTION LR
    [*] --> CONFIRMED: purchase-product
    CONFIRMED --> ROLLBACK : rollback-purchase

When the rollback window has expired (see the 'expiry' header field in the response), the link to rollback the purchase must not be published anymore.

Flow option 4: direct use of an asset

stateDiagram-v2
    DIRECTION LR
    [*] --> CONFIRMED: use-asset
    CONFIRMED --> ROLLBACK : rollback-purchase

When the rollback window has expired (see the 'expiry' header field in the response), the link to rollback the purchase must not be published anymore.