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(); if ($this->shippingAddress != null) { $request = array_merge($request, $this->shippingAddress->getNVPArray()); } if ($this->billingPeriod != null) { $request = array_merge($request, $this->billingPeriod->getNVPArray()); } if ($this->creditCard != null) { $request = array_merge($request, $this->creditCard->getNVPArray()); } if ($this->payerInformation != null) { $request = array_merge($request, $this->payerInformation->getNVPArray()); } if ($this->address != null) { $request = array_merge($request, $this->address->getNVPArray()); } return $request; }