@@ -7,24 +7,25 @@ import { token } from "../../payments/x402/components/constants";
77// Allow streaming responses up to 5 minutes
88export const maxDuration = 300 ;
99
10- export async function GET ( request : NextRequest ) {
11- const client = createThirdwebClient ( {
12- secretKey : process . env . THIRDWEB_SECRET_KEY as string ,
13- } ) ;
10+ const client = createThirdwebClient ( {
11+ secretKey : process . env . THIRDWEB_SECRET_KEY as string ,
12+ } ) ;
1413
15- const BACKEND_WALLET_ADDRESS = process . env . ENGINE_BACKEND_WALLET as string ;
16- // const BACKEND_WALLET_ADDRESS = process.env.ENGINE_BACKEND_SMART_WALLET as string;
17- const ENGINE_VAULT_ACCESS_TOKEN = process . env
18- . ENGINE_VAULT_ACCESS_TOKEN as string ;
19- const API_URL = `https://${ process . env . NEXT_PUBLIC_API_URL || "api.thirdweb.com" } ` ;
14+ const BACKEND_WALLET_ADDRESS = process . env . ENGINE_BACKEND_WALLET as string ;
15+ // const BACKEND_WALLET_ADDRESS = process.env.ENGINE_BACKEND_SMART_WALLET as string;
16+ const ENGINE_VAULT_ACCESS_TOKEN = process . env
17+ . ENGINE_VAULT_ACCESS_TOKEN as string ;
18+ // const API_URL = `https://${process.env.NEXT_PUBLIC_API_URL || "api.thirdweb.com"}`;
19+ const API_URL = "http://localhost:3030" ;
2020
21- const twFacilitator = facilitator ( {
22- baseUrl : `${ API_URL } /v1/payments/x402` ,
23- client,
24- serverWalletAddress : BACKEND_WALLET_ADDRESS ,
25- vaultAccessToken : ENGINE_VAULT_ACCESS_TOKEN ,
26- } ) ;
21+ const twFacilitator = facilitator ( {
22+ baseUrl : `${ API_URL } /v1/payments/x402` ,
23+ client,
24+ serverWalletAddress : BACKEND_WALLET_ADDRESS ,
25+ vaultAccessToken : ENGINE_VAULT_ACCESS_TOKEN ,
26+ } ) ;
2727
28+ export async function GET ( request : NextRequest ) {
2829 const paymentData = request . headers . get ( "X-PAYMENT" ) ;
2930 const queryParams = request . nextUrl . searchParams ;
3031
@@ -38,6 +39,7 @@ export async function GET(request: NextRequest) {
3839 }
3940
4041 const amount = queryParams . get ( "amount" ) || "0.01" ;
42+ const payTo = queryParams . get ( "payTo" ) ?? undefined ;
4143 const tokenAddress = queryParams . get ( "tokenAddress" ) || token . address ;
4244 const decimals = queryParams . get ( "decimals" ) || token . decimals . toString ( ) ;
4345 const waitUntil =
@@ -49,6 +51,7 @@ export async function GET(request: NextRequest) {
4951 method : "GET" ,
5052 paymentData,
5153 network : defineChain ( Number ( chainId ) ) ,
54+ payTo,
5255 price : {
5356 amount : toUnits ( amount , parseInt ( decimals ) ) . toString ( ) ,
5457 asset : {
0 commit comments