| Server IP : 112.84.131.71 / Your IP : 43.159.78.114 Web Server : nginx/1.28.0 System : Linux 1763701629066 6.8.0-53-generic #55-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 17 15:37:52 UTC 2025 x86_64 User : www ( 1001) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/www.lengcat.cn/wp-content/themes/onenav/iopay/notify/paypal/ |
Upload File : |
<?php
/*
* @Author: iowen
* @Author URI: https://www.iowen.cn/
* @Date: 2023-03-04 04:23:56
* @LastEditors: iowen
* @LastEditTime: 2023-03-06 09:35:40
* @FilePath: \onenav\iopay\notify\paypal\notify.php
* @Description: paypal
*/
if(!session_id()) session_start();
header('Content-type:text/html; Charset=utf-8');
ob_start();
require dirname(__FILE__) . '/../../../../../../wp-load.php';
ob_end_clean();
$config = iopay_get_option('paypal');
if (empty($config['user']) || empty($config['pass']) || empty($config['signature']) || empty($config['rate'])) {
exit('fail');
}
require_once get_theme_file_path('/iopay/sdk/paypal/api.php');
$paypal = new PayPal($config['user'], $config['pass'], $config['signature']);
$token = urlencode( $_REQUEST['token']);
//建立第二个API请求到PayPal,使用令牌作为ID,以获得支付授权的细节。
$nvpstr = array('TOKEN' => $token);
//进行API调用并将结果存储在一个数组中。 如果调用成功,显示授权细节,并提供一个动作来完成支付。 如果失败,显示错误
$result = $paypal->__call("GetExpressCheckoutDetails",$nvpstr);
$pay_num = $result["CORRELATIONID"];
$ack = strtoupper($result["ACK"]);
$order_num = $result["INVNUM"];
if (($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING')) {
$total_smount = $result['PAYMENTREQUEST_0_AMT'] + $result['PAYMENTREQUEST_0_SHIPDISCAMT'];
$currency_code = $_REQUEST['currencyCodeType'];
$nvpstr = array(
'TOKEN' => $token,
'PAYERID' => $_REQUEST['PayerID'],
'PAYMENTREQUEST_0_AMT' => $total_smount,
'PAYMENTREQUEST_0_PAYMENTACTION' => $_REQUEST['paymentType'],
'PAYMENTREQUEST_0_CURRENCYCODE' => $currency_code
);
//调用PayPal以完成付款,如果发生错误,则显示由此产生的错误
$result = $paypal->__call("DoExpressCheckoutPayment", $nvpstr);
$ack = strtoupper($result["ACK"]);
if ($ack != 'SUCCESS' && $ack != 'SUCCESSWITHWARNING') {
show_paypal_error($result);
exit;
} else {
$order_num = $_SESSION["paypal_num"];
$pay_price = round($total_smount * $config['rate'], 2);
$pay = array(
'pay_type' => 'paypal',
'pay_price' => $pay_price,
'pay_num' => $pay_num,
'other' => array(
'currency_code' => $currency_code,
'pay_price' => $total_smount,
'exchange_rate' => $config['rate'],
),
);
// 更新订单状态
$order = iopay_confirm_pay($order_num, $pay);
$ret = home_url();
if (isset($_SESSION['paypal_return']) && $_SESSION['paypal_return']) {
$ret = $_SESSION['paypal_return'];
}
wp_redirect($ret);
}
} else {
show_paypal_error($result);
exit();
}
function show_paypal_error($result){
$msg="";
$msg='<table width="100%"><tr><td colspan="2" class="header">The PayPal API has returned an error!</td></tr>';
foreach($result as $key => $value)
{
$msg.="<tr><td> $key:</td><td>$value</td>";
}
$msg.='</table>';
echo $msg;
}
exit();