/var/www/hkosl.com/innoutstorage2019/paypal/APIError.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
    
/*************************************************
     * APIError.php
     *
     * Displays error parameters.
     *
     * Called by DoDirectPaymentReceipt.php, TransactionDetails.php,
     * GetExpressCheckoutDetails.php and DoExpressCheckoutPayment.php.
     *************************************************/
    
require_once('../webadmin/configure.php');

    
$pid session_id();

    
$resArray $_SESSION['reshash'];

    if (!empty(
$session_data["nvpReqArray"]["PWD"])) {
        
$resArray["nvpReqArray"]["PWD"] = "";
    }
    if (!empty(
$session_data["nvpReqArray"]["USER"])) {
        
$resArray["nvpReqArray"]["USER"] = "";
    }
    if (!empty(
$session_data["nvpReqArray"]["SIGNATURE"])) {
        
$resArray["nvpReqArray"]["SIGNATURE"] = "";
    }

    
//todo: save content to database

    
if (isset($_SESSION['curl_error_no'])) {
        
$errorCode    $_SESSION['curl_error_no'];
        
$errorMessage $_SESSION['curl_error_msg'];
        
session_unset();
    } else {
        
$errorCode "N/A";
        
$errorMessage .= "<table>";
        foreach (
$resArray as $key => $value) {
            
$errorMessage .= "<tr><td> $key:</td><td>$value</td></tr>";
        }
        
$errorMessage .= "</table>";
    }

    
$sql "INSERT INTO sys_errorlog SET tag = 'Paypal Error', error_code = ?, error_msg = ?, createdate = NOW(), refno = ?, sessionid = ?,
useragent = ?, _session = ?, _server = ?
"
;

    
$parameters = array($errorCode$errorMessagevar_export($resArraytrue), $pid$_SERVER['HTTP_USER_AGENT'], var_export($_SESSIONtrue), var_export($_SERVERtrue));
    if (!(
$sth $dbh->prepare($sql))) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }

    if (!
$sth->execute($parameters)) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }
    
$_SESSION["error_msg"] = "PayPal 付款出錯,請與我們聯絡。";
    
header("Location: ../" $_SESSION["langcode"] . "/contactus.php");
    exit;