来自贝宝运费详情的未定义索引

时间:2017-03-30 10:07:49

标签: php paypal sandbox

我收到了来自PayPal运费详情的错误消息

  

注意:未定义的索引:SALUTATION in   第41行/var/www/html/pp/temp/review.php

     

注意:未定义的索引:MIDDLENAME in   第43行/var/www/html/pp/temp/review.php

     

注意:未定义的索引:/var/www/html/pp/temp/review.php中的SUFFIX   第45行

     

注意:未定义的索引:SHIPTOSTREET2 in   第50行/var/www/html/pp/temp/review.php

     

注意:未定义的索引:/var/www/html/pp/temp/review.php中的INVNUM   第56行

     

注意:未定义的索引:/var/www/html/pp/temp/review.php中的PHONENUM   在第57行

我试过这个

if( $ack == "SUCCESS" || $ack == "SUCESSWITHWARNING") 
    { 
          ///  echo '<pre>';print_r($resArray);exit;
        /*
        ' The information that is returned by the GetExpressCheckoutDetails call should be integrated by the partner into his Order Review 
        ' page      
        */
        $email              = $resArray["EMAIL"]; // ' Email address of payer.
        $payerId            = $resArray["PAYERID"]; // ' Unique PayPal customer account identification number.
        $payerStatus        = $resArray["PAYERSTATUS"]; // ' Status of payer. Character length and limitations: 10 single-byte alphabetic characters.
        $salutation         = $resArray["SALUTATION"]?$resArray["SALUTATION"]:''; // ' Payer's salutation.
        $firstName          = $resArray["FIRSTNAME"]; // ' Payer's first name.
        $middleName         = $resArray["MIDDLENAME"]?$resArray["MIDDLENAME"]:''; // ' Payer's middle name.
        $lastName           = $resArray["LASTNAME"]; // ' Payer's last name.
        $suffix             = $resArray["SUFFIX"]?$resArray["SUFFIX"]:''; // ' Payer's suffix.
        $cntryCode          = $resArray["COUNTRYCODE"]; // ' Payer's country of residence in the form of ISO standard 3166 two-character country codes.
        $business           = $resArray["BUSINESS"]; // ' Payer's business name.
        $shipToName         = $resArray["SHIPTONAME"]; // ' Person's name associated with this address.
        $shipToStreet       = $resArray["SHIPTOSTREET"]; // ' First street address.
        $shipToStreet2      = $resArray["SHIPTOSTREET2"]?$resArray["SHIPTOSTREET2"]:''; // ' Second street address.
        $shipToCity         = $resArray["SHIPTOCITY"]; // ' Name of city.
        $shipToState        = $resArray["SHIPTOSTATE"]; // ' State or province
        $shipToCntryCode    = $resArray["SHIPTOCOUNTRYCODE"]; // ' Country code. 
        $shipToZip          = $resArray["SHIPTOZIP"]; // ' U.S. Zip code or other country-specific postal code.
        $addressStatus      = $resArray["ADDRESSSTATUS"]; // ' Status of street address on file with PayPal   
        $invoiceNumber      = $resArray["INVNUM"]?$resArray["INVNUM"]:''; // ' Your own invoice or tracking number, as set by you in the element of the same name in SetExpressCheckout request .
        $phonNumber         = $resArray["PHONENUM"]?$resArray["PHONENUM"]:''; // ' Payer's contact telephone number. Note:  PayPal returns a contact telephone number only if your Merchant account profile settings require that the buyer enter one. 

    } 

但仍然是同一个问题。我如何解决这个问题?请帮帮我

1 个答案:

答案 0 :(得分:0)

use isset()函数用于检查是否设置了变量。 替换

$salutation         = $resArray["SALUTATION"]?$resArray["SALUTATION"]:''; 

 $salutation = $resArray["SALUTATION"] ?? "default"; (for php 7)
$var = isset($resArray["SALUTATION"]) ? $resArray["SALUTATION"] : "default"; (before php 7)

同样都是。