2013-09-06 2 views
0

github에서 찾은 merchant-sdk-php를 사용하여 문제를 찾는 데 문제가 있습니다. 어떤 이유로이 오류가 발생합니다. 나는 코드를 살펴 보았지만 그것을 견디거나 문제를 보지 않았다.PayPal PHP SDK의 버그 수정

치명적 오류 :/home/content/08/10639508/html/wp-content/plugins/donation-manager/library/vendor/paypal/paypal-sdk-core에서 정의되지 않은 메소드 stdClass :: toXMLString() 라인 - PHP - bc7822a/lib 디렉토리/PPXmlMessage.php 89

<?php 

/** * @author */ 추상 클래스 PPXmlMessage {

/** 
* @return string 
*/ 
public function toSOAP() 
{ 
    return $this->toXMLString(); 
} 



/** 
* @return string 
*/ 
public function toXMLString() 
{ 
    if (count($properties = get_object_vars($this)) >= 2 && array_key_exists('value', $properties)) { 
     $attributes = array(); 
     foreach (array_keys($properties) as $property) { 
      if ($property === 'value') continue; 
      if (($annots = PPUtils::propertyAnnotations($this, $property)) && isset($annots['attribute'])) { 
       if (($propertyValue = $this->{$property}) === NULL || $propertyValue == NULL) { 
        $attributes[] = NULL; 
        continue; 
       } 

       $attributes[] = $property . '="' . PPUtils::escapeInvalidXmlCharsRegex($propertyValue) . '"'; 
      } 
     } 

     if (count($attributes)) { 
      return implode(' ', $attributes) . '>' . PPUtils::escapeInvalidXmlCharsRegex($this->value); 
     } 
    } 

    $xml = array(); 
    foreach ($properties as $property => $defaultValue) { 
     if (($propertyValue = $this->{$property}) === NULL || $propertyValue == NULL) { 
      continue; 
     } 

     if (is_array($defaultValue) || is_array($propertyValue)) { 
      foreach ($propertyValue as $item) { 
       if (!is_object($item)) { 
        $xml[] = $this->buildProperty($property, $item); 
       }else{ 
        $xml[] = $this->buildProperty($property, $item); 
       } 
      } 

     } else { 
      $xml[] = $this->buildProperty($property, $propertyValue); 
     } 
    } 

    return implode($xml); 
} 



/** 
* @param string $property 
* @param PPXmlMessage|string $value 
* @param string $namespace 
* @return string 
*/ 
private function buildProperty($property, $value, $namespace = 'ebl') 
{ 
    $annotations = PPUtils::propertyAnnotations($this, $property); 
    if (!empty($annotations['namespace'])) { 
     $namespace = $annotations['namespace']; 
    } 
    if (!empty($annotations['name'])) { 
     $property = $annotations['name']; 
    } 

    $el = '<' . $namespace . ':' . $property; 
    if (!is_object($value)) { 
     $el .= '>' . PPUtils::escapeInvalidXmlCharsRegex($value); 

    } else { 
     if (substr($value = $value->toXMLString(), 0, 1) === '<' || $value=='') { 
      $el .= '>' . $value; 

     } else { 
      $el .= ' ' . $value; 
     } 
    } 

    return $el . '</' . $namespace . ':' . $property . '>'; 
} 



/** 
* @param array $map 
* @param string $prefix 
*/ 
public function init(array $map = array(), $prefix = '') 
{ 
    if (empty($map)) { 
     return; 
    } 

    if (($first = reset($map)) && !is_array($first) && !is_numeric(key($map))) { 
     parent::init($map, $prefix); 
     return; 
    } 

    $propertiesMap = PPUtils::objectProperties($this); 
    $arrayCtr = array();   
    foreach ($map as $element) { 

     if (empty($element) || empty($element['name'])) { 
      continue; 

     } elseif (!array_key_exists($property = strtolower($element['name']), $propertiesMap)) { 
      if (!preg_match('~^(.+)[\[\(](\d+)[\]\)]$~', $property, $m)) { 
       continue; 
      } 

      $element['name'] = $m[1]; 
      $element['num'] = $m[2]; 
     } 
     $element['name'] = $propertiesMap[strtolower($element['name'])]; 
     if(PPUtils::isPropertyArray($this, $element['name'])) {    
      $arrayCtr[$element['name']] = isset($arrayCtr[$element['name']]) ? ($arrayCtr[$element['name']]+1) : 0;    
      $element['num'] = $arrayCtr[$element['name']]; 
     } 
     if (!empty($element["attributes"]) && is_array($element["attributes"])) { 
      foreach ($element["attributes"] as $key => $val) { 
       $element["children"][] = array(
        'name' => $key, 
        'text' => $val, 
       ); 
      } 

      if (isset($element['text'])) { 
       $element["children"][] = array(
        'name' => 'value', 
        'text' => $element['text'], 
       ); 
      } 

      $this->fillRelation($element['name'], $element); 

     } elseif (!empty($element['text'])) { 
      $this->{$element['name']} = $element['text']; 

     } elseif (!empty($element["children"]) && is_array($element["children"])) { 
      $this->fillRelation($element['name'], $element); 
     } 
    }  
} 



/** 
* @param string $property 
* @param array $element 
*/ 
private function fillRelation($property, array $element) 
{ 
    if (!class_exists($type = PPUtils::propertyType($this, $property))) { 
     trigger_error("Class $type not found.", E_USER_NOTICE); 
     return; // just ignore 
    } 

    if (isset($element['num'])) { // array of objects 
     $this->{$property}[$element['num']] = $item = new $type(); 
     $item->init($element['children']); 

    } else { 
     $this->{$property} = new $type(); 
     $this->{$property}->init($element["children"]); 
    } 
} 

}

답변

0

귀하의 PaymentDetail 기록에서 json_encode/decode를 사용하고 있습니까? 페이팔 (PayPal)은 컴포넌트 클래스에 매우 특별한 것처럼 보입니다. stdClass (json_decode가 생성)는이를 자르지 않습니다. 일련 화는 작동하지만 사용에 대한 경고가 있습니다.

2

나는이 똑같은 오류를 가지고있다. (내 실제 응용 프로그램에서 - 그것은 내 테스트 코드에서 잘 작동했다.) 필자는 테스트 코드를 실제 환경으로 복사하고 내 자격 증명과 URL을 샌드 박스에서 라이브 페이지로 변경했을 때 실현되었다 ... 어떻게 든 SetExpressCheckout을 호출하기 전에 PaymentDetailsType 객체를 초기화하는 코드 행을 삭제했습니다. 따라서이 오류는 꽤 관련이없는 것 같았지만 PayPal을 호출하기 전에 개체를 설정하는 데 문제가있었습니다.