Getting "illegal parameter" when trying to call the alipay Payment API in the Sandbox

Error via Google Translate: '签名字段异常' -> 'Signature field exception'

  1. Validate the signature. Replace $privateKey and $publicKey from you secrets.
$data = 'POST ...';
$keyPair = openssl_pkey_new(
    [
        'private_key_bits' => 2048,
        'private_key_type' => OPENSSL_KEYTYPE_RSA,
    ]
);
openssl_pkey_export($keyPair, $privateKey);
$details = openssl_pkey_get_details($keyPair);
$publicKey = $details['key'];
openssl_sign($data, $signature, $privateKey, OPENSSL_ALGO_SHA256);
var_dump($signature);
//verify signature
$isValidSignature = openssl_verify(
    $data,
    $signature, 
    $publicKey, 
    'sha256WithRSAEncryption'
);
var_dump($isValidSignature);
  1. In the documentation says generatedSignature=base64UrlEncode(sha256withrsa(<Content_To_Be_Signed>), <privateKey>))

and provided java example

return URLEncoder.encode(new String(Base64.encodeBase64(signed), "UTF-8"), "UTF-8");

php equivalent is

urlencode(base64_encode($signature))