我为我的支付网关创建了一个codeigniter自定义库(My_payment_gate_way_init)..但是当我使用我的自定义库函数时,控制器(Billing)没有将参数传递到它显示的库中
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()on null in C:\ xampp \ htdocs \ debug_online \ application \ controllers \ Billing.php on 第576行
答案 0 :(得分:1)
在调用函数之前先创建一个对象。
$this->My_payment_gate_way_init = new My_payment_gate_way_init();
$this->My_payment_gate_way_init->setTransactionAmountforPay($ammount);