0
String ACCESS_CODE = "My_PAYFORTAcces_Code"
String MERCHANT_ID = "My_Payfory_Merchet_ID"

我发现了我认为问题在于签名生成的问题,我尝试使用字符串“<code>TESTSHAINaccess_code=ACCESS_CODEdevice_id=ffffffff-d6ab-d802-b274-478d7792a1b7language=enmerchant_identifier=MERCHANT_IDservice_command=SDK_TOKENTESTSHAIN”生成签名我得到了我的签名“<code>9c804f2c08e36749c75389afc12c50e68307c31052e6434c072cd5b36cc8c607” and when I tried with “<code>PASSaccess_code=ACCESS_CODElanguage=enmerchant_identifier=MERCHANT_IDmerchant_reference=53469903-eaac-459c-91b9-78cb026b0712service_command=TOKENIZATIONPASS” I got “<code>4568f58e22f46b75fb6157cbc131ab194e1f9a066bdc501171a018d2c1d22e14” as my signature.

一旦我尝试sdk_token使用两个签名生成,我得到“<code>{"response_code":"00008","re​​sponse_message":"Signature mismatch","service_command":"SDK_TOKEN","device_id":"ffffffff-d6ab -d802-b274-478d7792a1b7","签名":"30eb8f03adc12dd714aac83249ad0b3e763cfadcd6c996bdf49d86125c23335","merchant_identifier":"My_Payfory_Merchet_ID","access_code":"My_PAYFORTAcces_Code":"My_PAYFORTAcces_Code":"My_PAYFORTAcces_Code":"My_PAYFORTAcces_Code":"""是我生成签名的代码,请检查并让我知道它是否正确,

@TargetApi(Build.VERSION_CODES.KITKAT) 
    public static String generateSHA256(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException { 
        MessageDigest md = MessageDigest.getInstance("SHA-256"); 
        byte[] textBytes = text.getBytes(StandardCharsets.UTF_8); 
        md.update(textBytes, 0, textBytes.length); 
        byte[] sha1hash = md.digest(); 
        return convertToHex(sha1hash); 
    } 

    private static String convertToHex(byte[] data) { 
        StringBuilder buf = new StringBuilder(); 
        for (byte b : data) { 
            int halfbyte = (b >>> 4) & 0x0F; 
            int two_halfs = 0; 
            do { 
                buf.append((0 <= halfbyte) && (halfbyte <= 9) ? (char) ('0' + halfbyte) : (char) ('a' + (halfbyte - 10))); 
                halfbyte = b & 0x0F; 
            } while (two_halfs++ < 1); 
        } 
        return buf.toString(); 
    } 
4

2 回答 2

1

这解决了我的问题,

我更改了我的字符串以生成签名,

Constants.PayfortRequestPhrase + "access_code=" + Constants.PayfortAccessCode 
+ "device_id=" + deviceId + "language=enmerchant_identifier=" +
Constants.PayfortMerchantIdentifier + "service_command=SDK_TOKEN" + Constants.PayfortRequestPhrase 

RequestPhrase,我是从付费帐户中获得的AccessCodeMerchantIdentifier并且签名生成代码保持不变。

于 2018-12-27T13:41:31.250 回答
0

这对 Apple Pay 的生产没有问题。

public function createSignature($deviceId){
    $requestPhrase = PaymentHelper::paymentInfo('ap_request_phrase');
    $access_code = PaymentHelper::paymentInfo('ap_access_code');
    $merchant_identifier = PaymentHelper::paymentInfo('merchant_identifier');
    if (YII_ENV_DEV) {
        $seckey = '86qCkwevMaIwR3wFnilov.&(';
    } else {
        $seckey = $requestPhrase;
    }

    $sdkCredentials = [
        'service_command' => 'SDK_TOKEN',
        'merchant_identifier' => $merchant_identifier,
        'language' => $this->language,
        'device_id' => $deviceId,
        'access_code' => $access_code,
    ];

    $arrData = $sdkCredentials;
    $shaString  = '';

    ksort($arrData);
    foreach ($arrData as $key => $value) {
        $shaString .= "$key=$value";
    }

    $shaString = $seckey . $shaString . $seckey;
    $signature = hash("sha256", $shaString);

    $sdkCredentials['signature']  = $signature;
    
    return $sdkCredentials;
}
于 2021-02-23T12:03:04.930 回答