我为我的支付网关创建了一个代码点火器自定义库(My_payment_gate_way_init)。。但是当我使用我的自定义库函数时,控制器(计费)没有将参数传递到库中,它显示
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Billing::$My_payment_gate_way_init
Filename: controllers/Billing.php
Line Number: 576
当我使用时会出现错误
控制器
public function __construct()
{
parent::__construct();
$this->load->library('My_payment_gate_way_init');
}
function saveord(){
$ammount = $this->totlCost * 100;
$this->My_payment_gate_way_init->setTransactionAmountforPay($ammount);
}
库
class My_payment_gate_way_init
{
private $clientConfig;
private $initRequest;
private $transactionAmount;
private $redirect;
private $initResponse;
private $client;
private $CI;
function __construct()
{
$this->setTransactionAmountforPay();
}
function setTransactionAmountforPay($ammount=200){
// sets transaction-amounts details (all amounts are in cents)
$this->transactionAmount = new TransactionAmount();
$this->transactionAmount->setTotalAmount(0);
$this->transactionAmount->setServiceFeeAmount(0);
$this->transactionAmount->setPaymentAmount($ammount);
$this->transactionAmount->setCurrency("LKR");
$this->initRequest->setTransactionAmount($this->transactionAmount);
}
它还在底部显示了这个错误
致命错误:调用上的成员函数setTransactionAmountforPay()中为nullC: 上的''axamp''htdocs''debug_online''application''controllers''Billing.php576线
在调用函数之前先生成一个对象。
$this->My_payment_gate_way_init = new My_payment_gate_way_init();
$this->My_payment_gate_way_init->setTransactionAmountforPay($ammount);