You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PayFort SDK Token报无效命令:原生应用SDK Token获取请求出错

Fixing "PayFort SDK Token: Invalid command" Error

Hey there, let's work through this "Invalid command" error you're hitting when trying to get a PayFort SDK token. I've dealt with similar PayFort integration kinks before, so here's what to check first:

1. You're missing the mandatory command parameter

This is the most likely fix. PayFort's SDK token endpoint requires you to explicitly set the command parameter to SDK_TOKEN—I don't see this in your provided $requestParams array. Add it right at the top of your array like this:

$requestParams = array(
    'command' => 'SDK_TOKEN', // This line is non-negotiable!
    'access_code' => $this->PayfortAccessCode,
    'amount' => floatval($amount)*100,
    'currency' => strtoupper($currency),
    'customer_email' => $email,
    'merchant_reference' => $order_id,
    'order_description' => $order_description,
    'language' => $this->PayfortLanguage,
    'merchant_identifier' => $this->PayfortMerchantID,
    'payment_option' => $payment_option,
    // Make sure any other required params are added here too
);

2. Check for incomplete/truncated parameters

Your code snippet cuts off with comma...—make sure you haven't left out any required parameters or ended up with malformed key-value pairs. Double-check that all params are properly closed and no syntax errors are hiding in the truncated part of your code.

3. Verify parameter formatting rules

PayFort is picky about formatting, so confirm these details:

  • amount: You're already multiplying by 100 to convert to an integer (correct, since PayFort doesn't accept decimals directly)
  • currency: Must be a 3-letter ISO code (e.g., AED, USD) in uppercase—your strtoupper call is spot-on here
  • All string values should be free of unencoded special characters (most HTTP clients handle this automatically, but it's worth a quick check if you're using custom encoding)

4. Confirm you're using the correct endpoint

Make sure your request is going to the right environment URL:

  • Sandbox: https://sbpaymentservices.payfort.com/FortAPI/paymentApi
  • Production: https://paymentservices.payfort.com/FortAPI/paymentApi
    Sending to the wrong endpoint can sometimes throw misleading errors like "Invalid command".

5. Validate your signature (if required)

If your PayFort account requires a signature parameter (most do), double-check that you're generating it correctly. The signature is created by concatenating all request parameters in the specified order, hashing with your SHA request phrase (using SHA-256 or the algorithm set in your account), and adding it as a parameter to your request. A wrong signature can also trigger unexpected error messages.

Once you add the command parameter and verify all other details, test the request again (start with the sandbox environment if you can) and the error should resolve.

内容的提问来源于stack exchange,提问作者PHP User

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:57:17