test-apig-recharge.ps1 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Test saveRecharge with real order data from step 3
  2. # Order created: objectId=IqV8pb4PXw, detail.apigAuth.objectId=Vo3ROWEvDy
  3. $apigId = "Vo3ROWEvDy"
  4. # Test with fcompany (original field)
  5. Write-Host "=== saveRecharge (authComp, original) ===" -ForegroundColor Cyan
  6. $body1 = @{
  7. authComp = "test-openclaw-user"
  8. authid = $apigId
  9. apigid = $apigId
  10. oldCount = 0
  11. count = 100
  12. orderid = "IqV8pb4PXw"
  13. } | ConvertTo-Json -Compress
  14. try {
  15. $r1 = Invoke-RestMethod -Uri "https://server.fmode.cn/api/apig/saveRecharge" -Method POST -ContentType "application/json" -Body $body1 -TimeoutSec 60
  16. Write-Host "Response:" -ForegroundColor Green
  17. $r1 | ConvertTo-Json -Depth 5
  18. } catch {
  19. Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red
  20. if ($_.Exception.Response) {
  21. $reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream())
  22. Write-Host "Body: $($reader.ReadToEnd())" -ForegroundColor Yellow
  23. }
  24. }
  25. Write-Host ""
  26. # Test with user (new field)
  27. Write-Host "=== saveRecharge (user, new) ===" -ForegroundColor Cyan
  28. $body2 = @{
  29. user = "test-openclaw-user"
  30. authid = $apigId
  31. apigid = $apigId
  32. oldCount = 0
  33. count = 100
  34. orderid = "IqV8pb4PXw"
  35. } | ConvertTo-Json -Compress
  36. try {
  37. $r2 = Invoke-RestMethod -Uri "https://server.fmode.cn/api/apig/saveRecharge" -Method POST -ContentType "application/json" -Body $body2 -TimeoutSec 60
  38. Write-Host "Response:" -ForegroundColor Green
  39. $r2 | ConvertTo-Json -Depth 5
  40. } catch {
  41. Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red
  42. if ($_.Exception.Response) {
  43. $reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream())
  44. Write-Host "Body: $($reader.ReadToEnd())" -ForegroundColor Yellow
  45. }
  46. }