سلام و عرض ادب بنده کدها رو به شکل زیر زدم اما اروری که پیوست کردم نمایش داده میشه ضمن اینکه مرچنت کد درگاه زرین پال خودم رو وارد کردم و محدودیت ip هم نداره ممنون میشم راهنمایی بفرمایید
در فایل panel-pro>views>panel>wallet>index.php
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-title">
<h4>لیست کیف پول </h4>
</div>
<div class="card-body">
<div class="alert alert-info">
<p>
<span>موجودی کیف پول شما :</span>
<span>
<?php echo $user_wallet; ?>
</span>
</p>
</div>
<div class="payment-form">
<form class="form-inline" action="?action=payforwallet" method="post">
<div class="form-group mx-sm-3 mb-2">
<label for="amount" class="sr-only">مبلغ مورد نظر :</label>
<input type="number" class="form-control" name="amount" id="amount" placeholder="">
</div>
<button type="submit" name="startpayment" class="btn btn-primary mb-2">پرداخت </button>
</form>
</div>
</div>
</div>
</div>
</div>
در فایل panel-pro>services>payment.service.php
<?php
class PaymenrService
{
private $merchantID ;
private $client;
public function __construct()
{
$this -> merchantID = '88bc84d8-7472-11e8-8fbc-005056a205be';
$this -> client = new SoapClient('https://www.zarinpall.cpm/pg/services/WebGate/wsdl',
['encoding' => 'UTF-8']);
}
public function requestpayment($params)
{
$amount = $params['amount'];
$describtion = $params['describtion'];
$callback = $params['callback'];
$result = $this -> client -> PaymentRequest([
'merchantID' => $this -> merchantID,
'amount' => $amount ,
'describtion' => $describtion,
'callbackurl' => $callback ,
]);
$_SESSION['upp_amount'] = $amount ;
if( $result -> status ==100){
wp_redirect('https://www.zarinpall.com/pg/startpay' . $result -> authority);
exit;
}
}
public function verifypayment()
{
$authority = $_GET['authority'];
if($_GET['status'] == 'ok') {
$result = $this -> client -> PaymentVerification([
'merchantID' => $this -> merchantID,
'authority' => $authority,
'amount' => $_SESSION['upp_amount']
]);
if($result -> status ==100) {
echo 'Transaction success. RefID:' . $result -> RefID;
}else{
echo 'Transaction failed. status:' . $result -> status;
}
}else{
echo 'Transaction canceled by user';
}
}
}
در فایل panel-pro>panel>handlers>wallethandler.php
<?php
include "Handler.php";
include UPP_DIR . '/view.class.php';
include UPP_DIR . 'services/user.service.php';
include UPP_DIR . 'services/payment.service.php';
include_once UPP_DIR . "/utility/currency.class.php";
class WalletHandler extends Handler
{
public function __construct()
{
parent :: __construct();
add_action('upp_star_wallet_payment' , [$this ,'start_payment']);
}
public function index()
{
if($this -> hasaction()){
$this -> performactions();
return ;
}
$user_service = new UserService();
$currency = new Currency();
$user_wallet = $currency -> formattoman($user_service -> get_user_wallet($this -> current_user -> ID ));
view::load('panel.wallet.index' , compact('user_wallet'));
}
public function payforwallet()
{
if(isset($_POST['startpayment'])){
do_action('upp_star_wallet_payment');
}
view::load('panel.wallet.payforwallet');
}
public function start_payment()
{
$paymentservice = new PaymenrService();
$amount = intval($_POST['amount']);
$callback_url = home_url('/dashboard/wallet?action=verifypayment');
$paymentservice -> requestpayment([
'amount' => $amount,
'callback' => $callback_url,
'describtion' => sprintf('افزایش موجودی حساب کاربری به مبلغ %S' , $amount)
]);
}
public function verifypayment()
{}
}