---
# System prepended metadata

title: Purchuase Flow

---

## Purchase Flow

```plantuml
actor User
participant VTEX
collections "Checkout Page" as CheckoutPage
participant "Adapter VTEX" as Adapter
participant "Checkout API" as CheckoutAPI
database CheckoutDB
participant "Payments API" as Transfero

autonumber
User -> VTEX: Init checkout
VTEX -> Adapter: POST /api/payments
Adapter -> CheckoutAPI: POST /api/v1/order
CheckoutAPI -> CheckoutAPI: Validate if partner has enough limit
CheckoutAPI -> CheckoutDB: Persist into database
CheckoutAPI -> Adapter: Return redirectUrl (with token)
Adapter -> VTEX: Normalized response with paymentUrl 
VTEX -> User: Redirect command
User -> CheckoutPage: https://checkout.transfero.com/purchase?token=123456789
CheckoutPage -> CheckoutAPI: GET /api/v1/order-by-
CheckoutAPI -> CheckoutDB: Get Order data
CheckoutDB -> CheckoutAPI: Retrieve Order data
CheckoutAPI -> CheckoutPage: Retrieve purchase data
CheckoutPage -> User: Show checkout information for the user
User -> User: Validate checkout information
CheckoutPage-> CheckoutAPI: GET /api/v1/order-by-token/methods
CheckoutAPI -> CheckoutDB: Get methods configured for the Partner
CheckoutDB -> CheckoutAPI: Retrieve configured methods
CheckoutAPI -> CheckoutPage: Retrieve allowed payment methods
CheckoutPage -> User: Ask for select the payment method
User -> User: Select the desirable token and blockchain
User -> CheckoutPage: Submit choice for payment preview
CheckoutPage -> CheckoutAPI: POST /api/v1/order-by-token/preview
CheckoutAPI -> CheckoutDB: Get partner information
CheckoutDB -> CheckoutAPI: Retrieve partner information
CheckoutAPI -> Transfero: POST /api/v2/requestQuote
Transfero -> CheckoutAPI: Retrieve how much the user should deposit
CheckoutAPI -> CheckoutPage: Retrieve payment preview
CheckoutPage -> User: Show price preview for the user
User -> CheckoutPage: Confirm price and ask for deposit information
CheckoutPage -> CheckoutAPI: POST /api/v1/order-by-token/payment
CheckoutAPI -> CheckoutDB: Get partner information
CheckoutDB -> CheckoutAPI: Retrieve partner information
CheckoutAPI -> Transfero: POST /api/ramp/v1/swaporder
Transfero -> CheckoutAPI: Retrieve deposit information
CheckoutAPI -> CheckoutDB: Persist deposit information
CheckoutAPI -> CheckoutPage: Retrieve deposit information
CheckoutPage -> User: Show deposit information for User
User -> User: Makes the deposit
CheckoutPage -> CheckoutAPI: Polling in GET /api/v1/order-by-token/status
Transfero -> Transfero: Receive the deposit
Transfero -> CheckoutAPI: Notify via webhook the depositReceived
CheckoutAPI -> CheckoutDB: Update order status
CheckoutAPI -> CheckoutDB: Insert Transaction
CheckoutAPI -> Adapter: Notify payment completed
Adapter -> VTEX: Notify payment completed
CheckoutAPI -> CheckoutPage: Retrieve payment confirmation and redirectUrl
CheckoutPage -> User: Confirmation Page
CheckoutPage -> User: Redirect back to VTEX
User -> VTEX: Back at VTEX Checkout page
```