【发布时间】:2012-08-14 18:19:38
【问题描述】:
我需要使用 php 表单收集输入('x_amount'),然后将其发布到生成哈希的页面,然后将其发布到第三方站点。我不希望客户有一个两步过程,那么这可以用ajax和php来完成吗?这是我到目前为止所拥有的,但它需要被 ajaxified(我认为?)
<form action="https://globalgatewaye4.firstdata.com/pay" method="POST">
<?php
$x_login = "xxx-xxx"; // Take from Payment Page ID in Payment Pages interface
$transaction_key = "xxxxxxx"; // Take from Payment Pages configuration interface
$x_currency_code = "CAD"; // Needs to agree with the currency of the payment page
srand(time()); // initialize random generator for x_fp_sequence
$x_fp_sequence = rand(1000, 100000) + 123456;
$x_fp_timestamp = time(); // needs to be in UTC. Make sure webserver produces UTC
// The values that contribute to x_fp_hash
$hmac_data = $x_login . "^" . $x_fp_sequence . "^" . $x_fp_timestamp . "^" . $x_amount . "^" . $x_currency_code;
$x_fp_hash = hash_hmac('MD5', $hmac_data, $transaction_key);
echo ('<label>x_login</label><input name="x_login" type="hidden" value="' . $x_login . '">' );
echo ('<label>x_amount</label><input name="x_amount" type="hidden" value="' . $x_amount . '">' );
echo ('<label>x_fp_sequence</label><input name="x_fp_sequence" type="hidden" value="' . $x_fp_sequence . '">' );
echo ('<label>x_fp_timestamp</label><input name="x_fp_timestamp" type="hidden" value="' . $x_fp_timestamp . '">' );
echo ('<label>x_fp_hash</label><input name="x_fp_hash" type="hidden" value="' . $x_fp_hash . '" size="50">' );
echo ('<label>x_currency_code</label><input name="x_currency_code" type="hidden" value="' . $x_currency_code . '">');
?>
<input type="hidden" name="x_show_form" value="PAYMENT_FORM"/>
<input type="hidden" name="x_test_request" value="FALSE"/>
Enter Payment Amount:<br>
<input type="text" name="x_amount"/>
<input type="submit" value="Pay with Payment Pages"/>
</form>
也就是说,我可以一键收集x金额,生成哈希,然后将其发布给第三方吗?我怎样才能做到这一点?
【问题讨论】:
-
你的问题可以用 Ajax 来解决,但我觉得不行,你的登录名和哈希是服务器端的。
-
谢谢米海!我愿意接受有关如何使用 PHP 完成此服务器端的建议。我只需要一个基本的 html 页面来从客户那里收集金额(也可能是发票#),然后将其发布到第三方安全计费站点,在那里他们收集其余的计费信息并进行处理。