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); } }
public function getNVPRequest() { $request = $this->collection->getAllValues(); $request = array_merge($request, $this->creditCard->getNVPArray()); $request = array_merge($request, $this->payer->getNVPArray()); $request = array_merge($request, $this->address->getNVPArray()); foreach ($this->payment->getNVPArray() as $key => $value) { if (is_array($value)) { foreach ($value as $itemIndex => $item) { foreach ($item as $k => $v) { $request['L_' . $k . $itemIndex] = $v; } } } else { $request[$key] = $value; } } if ($this->secure3d != null) { $request = array_merge($request, $this->secure3d->getNVPArray()); } return $request; }