gpt4 book ai didi

php - 万事达卡支付集成服务无法在 PHP 中运行

转载 作者:可可西里 更新时间:2023-10-31 23:46:06 25 4
gpt4 key购买 nike

我使用了从 html 发布并传入 $postdata 数组的三个变量

    $cardnum= $_POST['Card_Num'];
$cardexp= $_POST['Card_Exp'];
$amount =$_POST['amount'];

在$postdata数组中传递这三个变量

$postdata = array(

"vpc_CardNum" => $cardnum,
"vpc_CardExp" => $cardexp,
"vpc_AccessCode" => $accessCode,
"vpc_Amount" => ($amount*100),
"vpc_Command" => 'pay',
"vpc_Locale" => 'en',
"vpc_MerchTxnRef" => $unique_id,
"vpc_Merchant" => $merchantId,
"vpc_OrderInfo" => 'this is a product',
"vpc_ReturnURL" => "https://localhost/success.php",
"vpc_Version" => '1');

完整的代码在给出的html下面给出:-

<!DOCTYPE html>

<html>
<head>
</head>
<body>

<form method="POST" action="integrate.php">
Credit Card Number
<input type="text" name="Card_Num">
<input type="text" name="Card_Exp" maxlength="4">
<input type="number" name="amount">
<input type="submit" value="Submit payment">

</form
</body>
</html>

下面给出了完整的 php 代码,它给出了 400 错误的状态

<?php

$cardnum= $_POST['Card_Num'];
$cardexp= $_POST['Card_Exp'];
$amount =$_POST['amount'];


$SECURE_SECRET = "YEOCOEN29B0785F1FF1E3C0FA8A3FUJK";
$accessCode = '546484645';
$merchantId = 'ABERCROMBIEKIDS#119GARDENCITYNY';


$cardnum= $_POST['Card_Num'];
$cardexp= $_POST['Card_Exp'];
$amount =$_POST['amount'];
$unique_id = rand(999999,8988888888);//this is a sample random no
$postdata = array(

"vpc_CardNum" => $cardnum,
"vpc_CardExp" => $cardexp,
"vpc_AccessCode" => $accessCode,
"vpc_Amount" => ($amount*100),
"vpc_Command" => 'pay',
"vpc_Locale" => 'en',
"vpc_MerchTxnRef" => $unique_id,
"vpc_Merchant" => $merchantId,
"vpc_OrderInfo" => 'this is a product',
"vpc_ReturnURL" => "https://localhost/success.php",
"vpc_Version" => '1');


$vpcURL = 'https://migs.mastercard.com.au/vpcpay?';
$md5Hash = $SECURE_SECRET;
$appendAmp = 0;


foreach ($postdata as $key => $value) {

if (strlen($value) > 0) {

if ($appendAmp == 0) {
$vpcURL .= urlencode($key) . '=' . urlencode($value);
$appendAmp = 1;
} else {
$vpcURL .= '&' . urlencode($key) . "=" . urlencode($value);
}
$md5Hash .= $value;
}
}

var_dump($postdata);
print_r($postdata);
if (strlen($SECURE_SECRET) > 0) {
$vpcURL .= "&vpc_SecureHash=" . strtoupper(md5($md5Hash));
}
header("Location: " . $vpcURL);

?>

最佳答案

vpc_ReturnURL 应该是实时服务器而不是您的 localhost,万事达卡(或 paypal .. 等)无法访问您的 localhost 和发布数据。


您如何看待 400 错误:

“400 错误请求”

“错误请求。您的浏览器发送了该服务器无法理解的请求。”

“错误的请求 - 无效的 URL”

“HTTP 错误 400 - 错误请求”

“错误请求:错误 400”

“HTTP 错误 400。请求主机名无效。”

“400 - 错误请求。由于语法格式错误,服务器无法理解该请求。客户端不应在未经修改的情况下重复该请求。”

关于php - 万事达卡支付集成服务无法在 PHP 中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36128429/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com