【问题标题】:EBS payment gateway: secure hash algorithmEBS 支付网关:安全哈希算法
【发布时间】:2015-09-22 18:52:46
【问题描述】:

我对计算哈希的方式有点困惑。集成指南和一些集成工具包根据所有排序参数计算(PHP 工具包已将这部分代码注释掉)。但是 PHP 集成工具包和一些在线教程仅从其中几个(密钥、帐户 ID、金额、订单、返回 url 和模式)计算请求哈希,并且确实有效。

我正在寻找这种状态的解释。

我在计算响应哈希时也遇到了一些困难。

$data = $config['secretKey'];
$hash = $params['SecureHash'];
unset($params['SecureHash']);
ksort($params);
foreach ($params as $param) {
    if (strlen($param) > 0) {
        $data .= '|' . $param;
    };
}
$data = hash($config['hashAlgoritm'], $data); // The same hash algorithm used for request
return $data == $hash;

而且响应似乎不包含 AccountID。

ResponseCode = '0'
ResponseMessage = 'Transaction Successful'
DateCreated = '2015-09-23 00:18:15'
PaymentID = '42609232'
MerchantRefNo = '223'
Amount = '1.00'
Mode = 'TEST'
BillingName = 'John Raj'
BillingAddress = 'Arcot Road'
BillingCity = 'Chennai'
BillingState = 'Tamil Nadu'
BillingPostalCode = '600001'
BillingCountry = 'IND'
BillingPhone = '04423452345'
BillingEmail = 'test@40test.test'
DeliveryName = 'John Esak'
DeliveryAddress = 'Arcot Road'
DeliveryCity = 'Chennai'
DeliveryState = 'Tamil Nadu'
DeliveryPostalCode  = '600001'
DeliveryCountry = 'IND'
DeliveryPhone = '04423452345'
Description = 'Test Order Description'
IsFlagged = 'NO'
TransactionID = '110978476'
PaymentMethod = '1001'
RequestID = '7331147'
SecureHash = 'f9101f3cbf53be4da75e51c208775953'

【问题讨论】:

    标签: php payment-gateway


    【解决方案1】:

    请求

    到目前为止,从密钥、帐户 ID、金额、参考号、返回 url 和模式计算请求哈希似乎是正确的方法。

    $hashData = 'The secret key';
    $hashType = 'md5'; // md5|sha1|sha250
    $hash .= "|" . urlencode($params['account_id']) . "|"
          . urlencode($params['amount']) . "|"
          . urlencode($params['reference_no']) . "|" 
          . $params['return_url'] . "|"
          . urlencode($params['mode']);
    return hash($hashType, $hashData);
    

    响应

    至于回复,我无法重建安全哈希的计算方式,或者即使安全哈希应该用于验证。所以我已经切换到使用加密版本的响应。

    EBS 没有指定应该使用哪种算法,但它似乎是某种 RC4 密码。

    要使用加密响应,返回 url 必须按照knowledgebase 中指定的格式表示:'http://www.yourdomainname.com/response.extension?DR={DR}'

    $DR = preg_replace("/\s/","+",$_GET['DR']);
    $rc4 = new Crypt_RC4($secret_key);
    $QueryString = base64_decode($DR);
    
    $rc4->decrypt($QueryString);
    $QueryString = explode('&',$QueryString);
    
    $response = array();
    foreach($QueryString as $param){
        $param = explode('=',$param);
        $response[$param[0]] = urldecode($param[1]);
    }
    return $response
    

    Crypt_RC43 类随后由 EBS 在 Rc43 文件 内提供,该文件是集成工具包的一部分。

    注意:Rc43 文件不是每个集成工具包的一部分。一些工具包甚至包括 Crypt_RC43 类作为控制器的私有内部类。对于我的实现,我使用了 Wordpress-3.7.x Donate integration kit 中包含的 Rc43 文件。

    【讨论】:

    猜你喜欢
    • 2013-03-08
    • 1970-01-01
    • 2017-05-25
    • 1970-01-01
    • 1970-01-01
    • 2019-07-17
    • 1970-01-01
    • 2013-11-28
    • 2011-12-30
    相关资源
    最近更新 更多