Bendigo Bank 告诉我,我们需要将 md5 更改为 SHA256。我已按照他们的说明进行操作,但出现此错误:
HTTP Status - 400
E5000: Cannot form a matching secure hash based on the merchant's request using either of the two merchant's secrets
他们的示例代码是这样的:
<?php foreach($_POST as $key => $value) {
if (strlen($value) > 0) { ?>
<input type="hidden" name="<?php echo($key); ?>" value="<?php echo($value); ?>"/><br>
<?php
if ((strlen($value) > 0) && ((substr($key, 0,4)=="vpc_") || (substr($key,0,5) =="user_"))) {
$hashinput .= $key . "=" . $value . "&";
}
}
}
$hashinput = rtrim($hashinput,"&");
?>
<!-- attach SecureHash -->
<input type="hidden" name="vpc_SecureHash" value="<?php echo(strtoupper(hash_hmac('SHA256', $hashinput, pack('H*',$securesecret)))); ?>"/>
<input type="hidden" name="vpc_SecureHashType" value="SHA256">
这是我的帖子:
Array (
[AgainLink] => http://fallscreekcountryclub.com.au/make-a-booking/submit-booking.html
[b_terms] => 1
[chargetypeid] => 33
[deposit] => 580.00
[notes] => 4 Nights - 26/11/2016 to 30/11/2016
[propertyid] => 2
[total] => 580.00
[vpc_AccessCode] => 903876BC
[vpc_Amount] => 58000
[vpc_Command] => pay
[vpc_Locale] => en
[vpc_MerchTxnRef] => 1479746896
[vpc_Merchant] => BBL5800396
[vpc_OrderInfo] => Studio Deluxe
[vpc_ReturnURL] => http://fallscreekcountryclub.com.au/make-a-booking/booking-complete.html
[vpc_Version] => 1
)
这是我的代码:
$appendAmp = 0;
$isencoded = '';
$notencoded = '';
foreach($_POST as $key => $value) {
if (strlen($value) > 0) {
if ($appendAmp == 0) :
$notencoded .= $key . '=' . $value;
$isencoded .= urlencode($key) . '=' . urlencode($value);
$appendAmp = 1;
else :
$notencoded .= '&' . $key . '=' . $value;
$isencoded .= '&' . urlencode($key) . '=' . urlencode($value);
endif;
}
}
if (strlen($SECURE_SECRET) > 0) {
#$vpcURL .= "&vpc_SecureHash=" . strtoupper(md5($md5HashData));
$SecureHash = strtoupper(hash_hmac('SHA256',$notencoded,pack('H*',$SECURE_SECRET)));
$SecureHashType = 'SHA256';
}
$vpcURL .= $notencoded.'&vpc_SecureHash='.$SecureHash.'&vpc_SecureHashType='.$SecureHashType;
我有“isencoded”和“notencoded”,因为我看到有人说在我构建 vpcURL 之前不要对 vpc_ReturnURL 的字符串进行 urlencode,但两者都不起作用。
vpcURL 的 urlencoded 版本是:
https://migs.mastercard.com.au/vpcpay?AgainLink=http%3A%2F%2Ffallscreekcountryclub.com.au%2Fmake-a-booking%2Fsubmit-booking.html&b_terms=1&chargetypeid=33&deposit=580.00¬es=4+Nights+-+26%2F11%2F2016+to+30%2F11%2F2016&propertyid=2&total=580.00&vpc_AccessCode=903876BC&vpc_Amount=58000&vpc_Command=pay&vpc_Locale=en&vpc_MerchTxnRef=1479746896&vpc_Merchant=BBL5800396&vpc_OrderInfo=Studio+Deluxe&vpc_ReturnURL=http%3A%2F%2Ffallscreekcountryclub.com.au%2Fmake-a-booking%2Fbooking-complete.html&vpc_Version=1&vpc_SecureHash=A5BA6503FC7A169A90C9AAC7039878F45D761180D874789172EB5A58298022E4&vpc_SecureHashType=SHA256
非 urlencoded 版本是:
https://migs.mastercard.com.au/vpcpay?AgainLink=http://fallscreekcountryclub.com.au/make-a-booking/submit-booking.html&b_terms=1&chargetypeid=33&deposit=580.00¬es=4 Nights - 26/11/2016 to 30/11/2016&propertyid=2&total=580.00&vpc_AccessCode=903876BC&vpc_Amount=58000&vpc_Command=pay&vpc_Locale=en&vpc_MerchTxnRef=1479746896&vpc_Merchant=BBL5800396&vpc_OrderInfo=Studio Deluxe&vpc_ReturnURL=http://fallscreekcountryclub.com.au/make-a-booking/booking-complete.html&vpc_Version=1&vpc_SecureHash=A5BA6503FC7A169A90C9AAC7039878F45D761180D874789172EB5A58298022E4&vpc_SecureHashType=SHA256
关于我做错了什么的任何想法?我调用银行,他们帮不了我,他们根本不知道我在说什么..
我知道 $SECURE_SECRET 数字是正确的,因为它与我用于原始 md5 哈希的数字相同。所以问题出在 sha256 哈希上,我不确定原因或如何修复它。
最佳答案
您好,我正在与您分享我的工作代码。 享受吧。
$secretHash="xxxxxx";
$accessCode='xxxxx';
$merchantId='xxxxx';
$data = array(
"vpc_AccessCode" => $accessCode,
"vpc_Amount" => '100',
"vpc_Command" => 'pay',
"vpc_Locale" => 'en',
"vpc_MerchTxnRef" => "REF_".time(),
"vpc_Merchant" => $merchantId,
"vpc_OrderInfo" => "Order_N_".time(),
"vpc_ReturnURL" => urlencode("yourReturnUrl"),
"vpc_Version" => '1',
'vpc_SecureHashType' => 'SHA256'
);
ksort($data);
$hash = null;
foreach ($data as $k => $v) {
if (in_array($k, array('vpc_SecureHash', 'vpc_SecureHashType'))) {
continue;
}
if ((strlen($v) > 0) && ((substr($k, 0, 4)=="vpc_") || (substr($k, 0, 5) =="user_"))) {
$hash .= $k . "=" . $v . "&";
}
}
$hash = rtrim($hash, "&");
$secureHash = strtoupper(hash_hmac('SHA256', $hash, pack('H*', $secretHash)));
$paraFinale = array_merge($data, array('vpc_SecureHash' => $secureHash));
$actionurl = 'https://migs.mastercard.com.au/vpcpay?'.http_build_query($paraFinale);
//print_r($actionurl);
header("Location:".$actionurl);
关于php - MIGS 在线支付 SHA256 HMAC 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40734309/
我正在尝试在Ruby中复制Convert.ToBase64String()行为。这是我的C#代码:varsha1=newSHA1CryptoServiceProvider();varpasswordBytes=Encoding.UTF8.GetBytes("password");varpasswordHash=sha1.ComputeHash(passwordBytes);returnConvert.ToBase64String(passwordHash);//returns"W6ph5Mm5Pz8GgiULbPgzG37mj9g="当我在Ruby中尝试同样的事情时,我得到了相同sha
我需要使用ActiveMerchant库在我们的一个Rails应用程序中设置支付解决方案。尽管这个问题非常主观,但人们对主要网关(BrainTree、Authorize.net等)的体验如何?它必须:处理定期付款。有能力记入个人帐户。能够取消付款。有办法存储用户的付款详细信息(例如Authotize.netsCIM)。干杯 最佳答案 ActiveMerchant很棒,但在过去一年左右的时间里,我在使用它时发现了一些问题。首先,虽然某些网关可能会得到“支持”——但并非所有功能都包含在内。查看功能矩阵以确保完全支持您选择的网关-http
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭9年前。我来自C、php和bash背景,很容易学习,因为它们都有相同的C结构,我可以将其与我已经知道的联系起来。然后2年前我学了Python并且学得很好,Python对我来说比Ruby更容易学。然后从去年开始,我一直在尝试学习Ruby,然后是Rails,我承认,直到现在我还是学不会,讽刺的是那些打着简单易学的烙印,但是对于我这样一个老练的程序员来说,我只是无法将它
我收到错误:unsupportedcipheralgorithm(AES-256-GCM)(RuntimeError)但我似乎具备所有要求:ruby版本:$ruby--versionruby2.1.2p95OpenSSL会列出gcm:$opensslenc-help2>&1|grepgcm-aes-128-ecb-aes-128-gcm-aes-128-ofb-aes-192-ecb-aes-192-gcm-aes-192-ofb-aes-256-ecb-aes-256-gcm-aes-256-ofbRuby解释器:$irb2.1.2:001>require'openssl';puts
一、离线方式1.1.下载ip2region.xdbGitHub项目地址:https://github.com/lionsoul2014/ip2region我们首先需要下载一个ip2region.xdb的文件下载地址:https://github.com/lionsoul2014/ip2region/blob/master/data/ip2region.xdb打开后点击如图的Download图标即可下载。下载完成后,需要将该文件放到我们的项目中。ps:我是直接放到服务器的,因为放在项目的资源文件夹下,当我们调试的时候使用JavaSpring自带的工具去获取该文件的绝对路径时,没有任何问题,能够正
这是两个脚本的故事,与previousquestion有关.这两个脚本位于http://gist.github.com/50692.ansi.rb脚本在所有256种背景颜色上显示所有256种颜色。ncurses.rb脚本显示所有256种前景颜色,但背景显示基本的16种颜色,然后似乎循环显示各种属性,如闪烁和反向视频。那么是什么给了?这是ncurses中的错误,它使用带符号的整数来表示颜色对吗?(即'tputcolors'表示256但'tputpairs'表示32767而不是65536)似乎如果是这种情况,颜色对的前半部分会正确显示但后半部分会重复或进入属性作为int包裹。
RubyCompass不工作,代码如下,我已经在网上尝试了10-20种方法,有什么建议吗?在屏幕截图中,您会找到一种更简单的方法来读取我的gem的终端转储和错误,如果您想从那里获取一些东西,您会在屏幕截图下方找到文本谢谢,干杯,罗伯特RubyGemsisasophisticatedpackagemanagerforRuby.Thisisabasichelpmessagecontainingpointerstomoreinformation.Usage:gem-h/--helpgem-v/--versiongemcommand[arguments...][options...]Examp
前言微信支付是企业级项目中经常使用到的功能,作为后端开发人员,完整地掌握该技术是十分有必要的。一、申请流程和步骤图1-1注册微信支付账号获取微信小程序APPID获取微信商家的商户ID获取微信商家的API私钥配置微信支付回调地址绑定微信小程序和微信支付的关系搭建SpringBoot工程编写后台支付接口发布部署接口服务项目使用微信小程序或者UniAPP调用微信支付功能支付接口的封装配置jwt或者openid的token派发原生微信小程序完成支付对接二、注册商家2.1商户平台商家或者企业想要通过微信支付来进行商品的销售,必须先通过微信平台(pay.weixin.qq.com)去将商家进行注册。注册成
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭10年前。我使用PHP的时间太长了,对它感到厌倦了。我也想学习一门新语言。我一直在使用Ruby并且喜欢它。我必须在Rails和Sinatra之间做出选择,那么您会推荐哪一个?Sinatra真的不能用来构建复杂的应用程序,它只能用于简单的应用程序吗?
当我使用Thread.new{}生成一个线程时,该线程中发生的任何异常似乎永远不会出现,应用程序只是悄悄地忽略它 最佳答案 通常情况下,线程是相互隔离的,因此一个线程中的异常不会终止整个应用程序。但是,虽然我从未使用过它们,但Thread类有几个abort_on_exception方法,甚至还有一些示例。他们应该做你想做的事。http://corelib.rubyonrails.org/classes/Thread.html 关于ruby-我如何让ruby在线程内输出异常?,我们在S