سلام و عرض ادب بنده کدها رو به شکل زیر زدم اما اروری که پیوست کردم نمایش داده میشه ضمن اینکه مرچنت کد درگاه زرین پال خودم رو وارد کردم و محدودیت 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()
{}
}
سلام خدمت شما. این خطا در مورد اتصال به سرویس زرین پال هست. اگر از پراکسی استفاده می کنی حتما خاموش کنید و دوباره تست کنید و اینکه کدهای جدید زرین پال رو هم از سایت خودش بررسی کنید.
سلام مجدد کدهای زرین پال رو بررسی کردم فقط دو نمونه سوروس کد برای php داره :
1- نمونه کد استفاده از درگاه زرین پال به زبان PHP بر اساس استاندارد REST
2- ZarinPal Advanced Class AND PHP Sample Code
که لینکش رو هم براتون میفرستم ممنون میشم بفرمایید کدومش رو و به چه روش میتونم استفاده بکنم ؟
https://www.zarinpal.com/lab/zarinpal-advanced-class-and-php-sample-code/
به نظرم اگر از حالتی که به صورت شی گرا نوشته شده استفاده کنید.
require_once("zarinpal_function.php");
$MerchantID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
$Amount = 100;
$Description = "تراکنش زرین پال";
$Email = "";
$Mobile = "";
$CallbackURL = "http://example.com/verify.php";
$ZarinGate = false;
$SandBox = false;
$zp = new zarinpal();
$result = $zp->request($MerchantID, $Amount, $Description, $Email, $Mobile, $CallbackURL, $SandBox, $ZarinGate);
if (isset($result["Status"]) && $result["Status"] == 100)
{
// Success and redirect to pay
$zp->redirect($result["StartPay"]);
} else {
// error
echo "خطا در ایجاد تراکنش";
echo "<br />کد خطا : ". $result["Status"];
echo "<br />تفسیر و علت خطا : ". $result["Message"];
}