Step 1: Obtain Access Token
Obtaining Access Token
Obtaining Access Token
Before using the Phoenix component, you need to obtain an access token from your backend.See the Obtaining Access Token page for detailed instructions on setting up the backend endpoint.
This is example code for obtaining an access token. You will need to adapt the endpoint URL and request format based on your specific backend implementation. Refer to the Obtaining Access Token page for a complete example of setting up a backend service.
Step 2: Download the Component
You can view the component code or download it directly:View Component Code
View Component Code
PhoenixPayment.tsx
/src/components/PhoenixPayment.tsx
The component includes all necessary styling internally via the
<style> tag, so you don’t need to add any additional CSS.Step 3: Implement the Component
Follow these steps to implement the component in your application:Step 3.1: Import the Component
Step 3.2: Prepare Required and Optional Parameters
Before adding the component, you need to collect the following information:Required Parameters
walletAddress: The Ethereum wallet address where USDC will be sentamount: The amount in USD to convert to USDCaccessToken: The access token retrieved from your backendonClose: Function to handle when the user closes the payment modalonComplete: Callback function to handle payment completion events
Optional Parameters
onDone: Callback function to handle when the payment process is completeonOrderCreated: Optional callback function to handle when an order is createdtheme: Optional UI theme, can be set to either ‘light’ or ‘dark’
View Input Collection Example
View Input Collection Example
Step 3.3: Add the Component to Your JSX
Once you have collected these values, you can pass them to the PhoenixPayment component:Step 3.4: Handle Order Created Events
TheonOrderCreated callback is triggered when a new order is created in the Phoenix system. This happens before the payment process begins. The callback receives an object containing:
order_id: Unique identifier for the orderdata: Object containing additional order details:created_at: Timestamp of order creationbuyer_address: The buyer’s wallet addressseller_address: The seller’s wallet addresssend_amount: The amount to be sentreceive_amount: The amount to be receiveduniqueness_amount: The amount of cents added to the order for uniquenessreceiving_chain_id: The chain ID where the payment will be receivedzelle_address: The Zelle address for payment
Step 3.5: Handle Payment Completion
TheonComplete callback receives three parameters:
success: Boolean indicating if the operation succeededtransactionId: Transaction hash (only for successful payments)data: Object containing additional information
Transaction Success Data
When a transaction is successful, the data object will contain:amount: The USD amounttoken: The token received (e.g., “USDC”)chain: The blockchain (e.g., “Base”)walletAddress: The receiving wallet addresssendAmount: The amount of tokens senttransactionHash: The blockchain transaction hashbasescanLink: Link to view the transaction on Basescan
Step 3.6: Handle Done Events
Full Implementation Example
View Complete Example
View Complete Example
Here’s a complete example showing how all the pieces fit together: