# Test the full payment flow with a real userId # Step 1: Create order with real userId # Step 2: Generate QR code # Step 3: Check if saveRecharge works with real userId $realUserId = "nd7NOCmFiE" $apigId = "Vo3ROWEvDy" $ct = @{ "Content-Type" = "application/json" } Write-Host "=== Test with real userId: $realUserId ===" -ForegroundColor Cyan Write-Host "" # Step 1: Create order with real userId (using fcompany which works) $now = Get-Date $tradeNo = "CREAL" + $now.ToString("yyyyMMddHHmmssfff") Write-Host "TradeNo: $tradeNo" $orderBody = @{ fcompany = $realUserId user = $realUserId type = "wxpay" authid = $apigId params = @{ out_trade_no = $tradeNo total_fee = 0.01 body = "test recharge" } apigid = $apigId oldCount = 99999 count = 1 } | ConvertTo-Json -Depth 3 -Compress Write-Host "=== Creating order ===" -ForegroundColor Cyan try { $orderResp = Invoke-RestMethod -Uri "https://server.fmode.cn/api/apig/created-apigorder" -Method POST -ContentType "application/json" -Body $orderBody -TimeoutSec 60 Write-Host "Order response:" -ForegroundColor Green $orderResp | ConvertTo-Json -Depth 8 $orderId = $orderResp.data.objectId $apigAuthId = $orderResp.data.detail.apigAuth.objectId Write-Host "" Write-Host "orderId: $orderId" -ForegroundColor Yellow Write-Host "apigAuthId: $apigAuthId" -ForegroundColor Yellow } catch { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red $orderId = "" $apigAuthId = "" } Write-Host "" # Step 2: Test saveRecharge with real userId and order if ($orderId) { Write-Host "=== Testing saveRecharge ===" -ForegroundColor Cyan $rechargeBody = @{ user = $realUserId authComp = $realUserId fcompany = $realUserId authid = $apigId apigid = $apigAuthId oldCount = 99999 count = 1 orderid = $orderId } | ConvertTo-Json -Compress Write-Host "Recharge body: $rechargeBody" try { $rechargeResp = Invoke-RestMethod -Uri "https://server.fmode.cn/api/apig/saveRecharge" -Method POST -ContentType "application/json" -Body $rechargeBody -TimeoutSec 60 Write-Host "Recharge response:" -ForegroundColor Green $rechargeResp | ConvertTo-Json -Depth 5 } catch { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red if ($_.Exception.Response) { $reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream()) Write-Host "Body: $($reader.ReadToEnd())" -ForegroundColor Yellow } } } Write-Host "" # Step 3: Check if getApig now returns data (APIGAuth might have been created) Write-Host "=== Check getApig after order ===" -ForegroundColor Cyan $body3 = @{ authid = $apigId } | ConvertTo-Json -Compress try { $r3 = Invoke-WebRequest -Uri "https://server.fmode.cn/api/apig/getApig" -Method POST -ContentType "application/json" -Body $body3 -TimeoutSec 15 Write-Host "getApig response: $($r3.Content)" -ForegroundColor Green } catch { Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red }