Jupiter on payments

 
This documentation outlines the implementation of a payment system using Jupiter for token swaps and Solana for transactions. The system allows users to pay with any token while receiving a stablecoin (USDC).

Token Fetching

  • Fetches user token accounts
  • Retrieves mint information and prices for each token
  • Filters tokens based on a minimum value threshold (price)
  • Includes SOL balance if it meets the threshold
  • Caches mint and metadata information from Firebase db

Token Picker Component

  • Displays a dropdown of available tokens
  • Shows token symbols and images
  • Calculates and displays the payment amount based on selected token and quantity
  • Includes a payment button and wallet disconnect option

Transaction Flow

  • Server-side operations:
    • Transaction creation
    • RPC calls
    • Jupiter integration (in case the user pays with a mint other than USDC)
    • Transaction confirmation
    • Validation of transaction details
  • Client-side operation: Transaction signing by the user
  • Transaction flow: 1. Client requests transaction creation 2. Server creates and returns the transaction 3. Client signs the transaction 4. Client sends signed transaction for confirmation 5. Server confirms and processes the transaction
  • Post-confirmation process:
    • Transaction validation (amount, seller, currency)
    • Saving transaction details in Firebase database
  • Security benefits:
    • RPC key remains hidden on the server
    • Only the necessary signing step is done client-side
  • Flexibility: Supports various tokens through Jupiter integration