我在处理付款时收到了自定义付款wordpress插件的错误消息,例如:
解析错误:语法错误,意外的T_PUBLIC in /home/galer258/public_html/dev/wp-content/plugins/bcasakuku/result.php 在第3行
或请查看this link以获取更多信息。
此处为result.php脚本
<?php
public function doPayment(){
$_POST = json_decode(file_get_contents("php://input"), 1);
if( $_SERVER['REQUEST_METHOD'] == 'POST' ){
if( isset( $_POST['MerchantID'] ) AND isset( $_POST['TransactionID'] ) AND isset( $_POST['TransactionReffID'] ) AND isset( $_POST['Signature'] ) ){
//VALIDATE MERCHANT ID
if( $_POST['MerchantID'] == $_POST['MerchantID'] ){
$orders = $_POST['TransactionID'];
if( $orders AND is_numeric( $_POST['TransactionID'] ) ){
if( $orders['order_status_id'] == $this->$_POST['TransactionID'] {
$sakukuOrder = $_POST['TransactionID'];
if( $sakukuOrder ){
$str = $sakukuOrder['AccToken'].$sakukuOrder['TransactionID'].$sakukuOrder['Amount'].$sakukuOrder['PaymentID'];
$validate = strtoupper( hash('sha256', $str) );
if( $_POST['Signature'] == $validate ){
$this->$sakukuOrder['TransactionID'], 5;
$this->generateOutput( 0, "00" );
}else{
$this->generateOutput( 1, "01" );
}
}else{
$this->generateOutput( 1, "01" );
}
}else{
$this->generateOutput( 2, "01" );
}
}else{
$this->generateOutput( 1, "01" );
}
}else{
$this->generateOutput( 1, "01" );
}
}else{
$this->generateOutput( 1, "01" );
}
}else{
$this->generateOutput( 1, "01" );
}
}
private function generateOutput( $rs, $status ){
$reason = array(
"Indonesian" => array("Sukses","Transaksi tidak dapat diproses.","Transaksi sudah dibayar."),
"English" => array("Success","Transaction cannot be processed.","Transaction has been paid."),
);
$output = array(
"MerchantID" => ( !isset( $_POST['MerchantID'] ) ) ? '' : $_POST['MerchantID'],
"TransactionID" => ( !isset( $_POST['TransactionID'] ) ) ? '' : $_POST['TransactionID'],
"FlagStatus" => "01",
"ReasonStatus" => array( "Indonesian" => "", "English" => "" )
);
$output['FlagStatus'] = $status;
$output['ReasonStatus']['Indonesian'] = $reason['Indonesian'][ $rs ];
$output['ReasonStatus']['English'] = $reason['English'][ $rs ];
echo json_encode($output);
}
?>
您可以尝试使用BCA sakuku作为付款选项购买一件产品on this link,如下图所示:
非常感谢任何帮助。
更新#1:
这里是最新的result.php脚本
<?php
function doPayment(){
$_POST = json_decode(file_get_contents("php://input"), 1);
if( $_SERVER['REQUEST_METHOD'] == 'POST' ){
if( isset( $_POST['MerchantID'] ) AND isset( $_POST['TransactionID'] ) AND isset( $_POST['TransactionReffID'] ) AND isset( $_POST['Signature'] ) ){
//VALIDATE MERCHANT ID
if( $_POST['MerchantID'] == $_POST['MerchantID'] ){
$sakukuOrder = $_POST['TransactionID'];
$orders = $_POST['TransactionID'];
if( $orders AND is_numeric( $_POST['TransactionID'] ) ){
if( $orders['order_status_id'] == $this->$_POST['TransactionID'] {
if( $sakukuOrder ){
$str = $sakukuOrder['AccToken'].$sakukuOrder['TransactionID'].$sakukuOrder['Amount'].$sakukuOrder['PaymentID'];
$validate = strtoupper( hash('sha256', $str) );
if( $_POST['Signature'] == $validate ){
$this->$sakukuOrder['TransactionID'], 5;
$this->generateOutput( 0, "00" );
}else{
$this->generateOutput( 1, "01" );
}
}else{
$this->generateOutput( 1, "01" );
}
}else{
$this->generateOutput( 2, "01" );
}
}else{
$this->generateOutput( 1, "01" );
}
}else{
$this->generateOutput( 1, "01" );
}
}else{
$this->generateOutput( 1, "01" );
}
}else{
$this->generateOutput( 1, "01" );
}
}
private function generateOutput( $rs, $status ){
$reason = array(
"Indonesian" => array("Sukses","Transaksi tidak dapat diproses.","Transaksi sudah dibayar."),
"English" => array("Success","Transaction cannot be processed.","Transaction has been paid."),
);
$output = array(
"MerchantID" => ( !isset( $_POST['MerchantID'] ) ) ? '' : $_POST['MerchantID'],
"TransactionID" => ( !isset( $_POST['TransactionID'] ) ) ? '' : $_POST['TransactionID'],
"FlagStatus" => "01",
"ReasonStatus" => array( "Indonesian" => "", "English" => "" )
);
$output['FlagStatus'] = $status;
$output['ReasonStatus']['Indonesian'] = $reason['Indonesian'][ $rs ];
$output['ReasonStatus']['English'] = $reason['English'][ $rs ];
echo json_encode($output);
}
?>
收到另一条错误消息,例如:
解析错误:语法错误,意外的T_IF在 /home/galer258/public_html/dev/wp-content/plugins/bcasakuku/result.php 第18行
那我该如何解决呢?
答案 0 :(得分:1)
public
关键字仅用于class
内的函数/变量声明。由于您未使用class
,因此需要将其从代码中删除。