コード例 #1
0
 public function __construct($response, Environment $environment)
 {
     parent::__construct($response, $environment);
     $responseArray = array();
     $info = array();
     $error = array();
     foreach ($this->getResponse() as $key => $value) {
         $keyParts = explode('_', $key);
         if (!empty($keyParts)) {
             if ($keyParts[0] == 'PAYMENTINFO') {
                 $x = $keyParts[1];
                 /* [index][key] = value  */
                 $info[$x][$keyParts[2]] = $value;
             } elseif ($keyParts[0] == 'PAYMENTREQUEST') {
                 $x = $keyParts[1];
                 /* [index][key] = value  */
                 $error[$x][$keyParts[2]] = $value;
             }
         } else {
             $responseArray[$key] = $value;
         }
     }
     $this->collection = new Collection(self::$allowedValues, $responseArray);
     foreach ($info as $index => $value) {
         $this->paymentInfo[$index] = PaymentInfo::getResponse($value);
     }
     foreach ($error as $index => $value) {
         $this->paymentError[$index] = PaymentError::getResponse($value);
     }
     $this->userOptions = UserOptions::getResponse($responseArray);
 }
コード例 #2
0
 public function __construct($response, Environment $environment)
 {
     parent::__construct($response, $environment);
     $responseArray = $this->getResponse();
     if (!empty($responseArray)) {
         $this->payerInformation = PayerInformation::getResponse($responseArray);
         $this->payerName = PayerName::getResponse($responseArray);
         $this->userOptions = UserOptions::getResponse($responseArray);
     }
     $responseArray = array();
     /* payment request */
     $payments = array();
     foreach ($this->getResponse() as $key => $value) {
         $keyParts = explode('_', $key);
         if (!empty($keyParts)) {
             // PAYMENTREQUEST_n_VALUE
             if ($keyParts[0] == 'PAYMENTREQUEST') {
                 $x = $keyParts[1];
                 /* [index][key] = value  */
                 $payments[$x][$keyParts[2]] = $value;
                 // L_PAYMENTREQUEST_n_VALUEn
             } elseif ($keyParts[0] == 'L' && count($keyParts) > 3) {
                 $x = $keyParts[2];
                 $rawValue = $keyParts[3];
                 preg_match('/[\\d]+$/', $rawValue, $matches);
                 if (count($matches) == 1) {
                     $size = strlen($rawValue);
                     $index = $matches[0];
                     $indexSize = strlen($index);
                     $value = substr($rawValue, 0, $size - $indexSize);
                     $payments[$x][$index] = $value;
                 }
             }
         } else {
             $responseArray[$key] = $value;
         }
     }
     $this->collection = new Collection(self::$allowedValues, $responseArray);
     /* set payments */
     foreach ($payments as $index => $value) {
         $this->payment[$index] = Payment::getResponse($value);
     }
 }