我正在为 opencart 创建一个自定义网关模块,但代码中有一些问题。你能告诉我我做错了什么吗?
opencart 调试器显示错误:
[03-Oct-2013 06:50:02 America/Chicago] PHP Fatal error: Call to undefined method ControllerPaymentMyBank::check_order() in /home/***/public_html/catalog/controller/payment/mybank.php on line 207
[03-Oct-2013 06:50:34 America/Chicago] PHP Fatal error: Call to undefined method ControllerPaymentMyBank::ResponseToBank() in /home/***/public_html/catalog/controller/payment/mybank.php on line 225
我使用的功能:
public function callback() {
//SOME CODE HERE WORKS....
$xml = xml_parser_create('UTF-8');
xml_parse_into_struct($xml, html_entity_decode($_POST['ConfirmRequest']), $vals);
xml_parser_free($xml);
foreach ($vals as $data)
{
if ($data['tag']=='STATUS')
$Status=$data['value'];
if ($data['tag']=='PAYMENTID')
$PaymentId=$data['value'];
if ($data['tag']=='PAYMENTDATE')
$PaymentDate=$data['value'];
if ($data['tag']=='TRANSACTIONID')
$TransactionId=$data['value'];
if ($data['tag']=='AMOUNT')
$Amount=$data['value'];
if ($data['tag']=='REASON')
$Reason=$data['value'];
if ($data['tag']=='CARDTYPE')
$CardType=$data['value'];
}
if($Status=='C')
{
if($this->check_order($TransactionId,$Amount))
$this->ResponseToBank($TransactionId,$PaymentId,'ACCEPTED');
else
$this->ResponseToBank($TransactionId,$PaymentId,'DECLINED');
}
if($Status=='Y')
{
if( $this->success_order($TransactionId) )
$this->ResponseToBank($TransactionId,$PaymentId,'ACCEPTED');
else
$this->ResponseToBank($TransactionId,$PaymentId,'DECLINED');
}
$this->ResponseToBank($TransactionId,$PaymentId,'ACCEPTED');
function ResponseToBank($TransactionId,$PaymentId,$Status)
{
$xmlstr = "<ConfirmResponse>";
$xmlstr .= "<TransactionId>".$TransactionId."</TransactionId>";
$xmlstr .= "<PaymentId>".$PaymentId."</PaymentId>";
$xmlstr .= "<Status>".$Status."</Status>";
$xmlstr .= "</ConfirmResponse>";
header('Content-type: text/xml');
die($xmlstr);
}
function check_order($orderid,$amount)
{
return true;
}
function success_order($orderid)
{
return true;
}
}
我该如何定义这些方法?