Woocommerce WoCommerce对WP API挂钩的POST请求未工作
我定制了Woocommerce支付网关,一切正常,直到我必须通过外部支付链接返回api响应的网站。我得到-1空白页,网络状态为400错误(错误请求)。任何帮助都是非常感谢的。谢谢Woocommerce WoCommerce对WP API挂钩的POST请求未工作,woocommerce,woocommerce-rest-api,Woocommerce,Woocommerce Rest Api,我定制了Woocommerce支付网关,一切正常,直到我必须通过外部支付链接返回api响应的网站。我得到-1空白页,网络状态为400错误(错误请求)。任何帮助都是非常感谢的。谢谢 $this->notify_url = str_replace( 'https:', 'http:', add_query_arg( 'wc-api', 'pm_wc_ncm', home_url( '/' ) ) ); add_action( 'woocommerce_api_pm_wc_
$this->notify_url = str_replace( 'https:', 'http:', add_query_arg( 'wc-api', 'pm_wc_ncm', home_url( '/' ) ) );
add_action( 'woocommerce_api_pm_wc_ncm', array( $this, 'check_notify_response' ) );
function check_notify_response(){
if (isset($_POST['txtIndex'])) {
$order_id = $_POST['txtIndex'];
$order = new WC_Order($order_id);
$order_total = $order->get_total();
$amount_paid = $_POST['txtAmount'];
$RespVal = $_POST['RespVal'];
$RespMsg = $_POST['RespMsg'];
$txtIndex = $_POST['txtIndex'];
$txtMerchNum = $_POST['txtMerchNum'];
$txtNumAut = $_POST['txtNumAut'];
$Signature = $_POST['signature'];
$txtCurrency = $_POST['txtCurrency'];
$sha = $this->sha_key;
$SignatureElts = $txtMerchNum . $order_id . $amount_paid . $txtCurrency . $txtNumAut . $RespVal . $RespMsg . $sha;
$ReturnSignature = hash('sha256', $SignatureElts);
if ($ReturnSignature != $Signature) {
echo "Security violation was detected! <br>";
echo "Order ID: ".$txtIndex."<br>";
$message1 = "Signature error";
if (function_exists('wc_add_notice')) {
wc_add_notice($message1, 'error');
}
}else{
if($RespVal=="1")
{
echo "Your Transaction was successful <br>";
echo "Order ID: ".$txtIndex."<br>";
echo "Authorization no.: ".$txtNumAut."<br>";
echo "Amount: ".$amount_paid."<br>";
}
elseif ($RespVal=="0")
{
echo "Unfortunately your transaction was refused <br>";
echo "Order ID: ".$txtIndex."<br>";
echo "Amount: ".$amount_paid."<br>";
}
}
}
}
$this->notify_url=str_replace('https:','http:',add_query_arg('wc api','pm_wc_ncm',home_url('/'));
添加动作('woocommerce\u api\u pm\u wc\u ncm',数组('check\u notify\u response');
功能检查\通知\响应(){
如果(isset($_POST['txtIndex'])){
$order_id=$\u POST['TXTDINDEX'];
$order=新WC\U订单($order\U id);
$order_total=$order->get_total();
$amount_paid=$_POST['txtAmount'];
$RespVal=$_POST['RespVal'];
$RespMsg=$_POST['RespMsg'];
$txtIndex=$_POST['txtIndex'];
$txtMerchNum=$_POST['txtMerchNum'];
$txtNumAut=$_POST['txtNumAut'];
$Signature=$_POST['Signature'];
$txtCurrency=$_POST['txtCurrency'];
$sha=$this->sha_键;
$SignatureElts=$txtMerchNum.$order_id.$amount_paid.$txtCurrency.$txtNumAut.$RespVal.$RespMsg.$sha;
$ReturnSignature=hash('sha256',$SignatureElts);
如果($ReturnSignature!=$Signature){
echo“检测到安全冲突!
”;
回显“订单ID:.$TXTDINDEX.”
“;
$message1=“签名错误”;
如果(功能_存在('wc_添加_通知')){
wc_添加_通知($message1,“error”);
}
}否则{
如果($RespVal==“1”)
{
echo“您的交易成功
”;
回显“订单ID:.$TXTDINDEX.”
“;
echo“授权编号:”$txtNumAut.“
”;
回显“金额:.$Amount_paid.”
“;
}
elseif($RespVal==“0”)
{
echo“很遗憾,您的交易被拒绝
”;
回显“订单ID:.$TXTDINDEX.”
“;
回显“金额:.$Amount_paid.”
“;
}
}
}
}