public function __construct($response, Environment $environment)
 {
     parent::__construct($response, $environment);
     $this->collection = new Collection(self::$allowedValues, $this->getResponse());
     $responseArray = $this->getResponse();
     if (!empty($responseArray)) {
         $this->recurringPaymentsProfile = RecurringPaymentsProfile::getResponse($responseArray);
         $this->shippingAddress = ShippingAddress::getResponse($responseArray);
         $this->billingPeriod = BillingPeriod::getResponse($responseArray);
         $this->recurringPaymentsSummary = RecurringPaymentsSummary::getResponse($responseArray);
         $this->creditCard = CreditCard::getResponse($responseArray);
         $this->payer = Payer::getResponse($responseArray);
         $this->address = Address::getResponse($responseArray);
     }
 }
Example #2
0
 /**
  * @param array $response nvp response represented as an array, array needs
  * to contain only keys without 'PAYMENTREQUEST_n_', if key starts with
  * 'L_PAYMENTREQUEST_n_...m' it needs to be converted into an array.
  *
  * @return Payment as response
  */
 public static function getResponse(array $response)
 {
     $payment = new self($response);
     $payment->request = false;
     $paymentResponse = array();
     foreach ($response as $key => $value) {
         /* array is on of the items */
         if (is_array($value)) {
             $item = PaymentItem::getResponse($value);
             $nvpArray = $item->getNVPArray();
             if (!empty($nvpArray)) {
                 $items[] = $item;
                 continue;
             }
             $item = EbayItem::getResponse($value);
             $nvpArray = $item->getNVPArray();
             if (!empty($nvpArray)) {
                 $items[] = $item;
                 continue;
             }
         } else {
             $paymentResponse[$key] = $value;
         }
     }
     /* set payment fields */
     $payment->collection = new Collection(self::$allowedValues, $paymentResponse);
     /* address */
     $address = ShippingAddress::getResponse($paymentResponse);
     $nvpArray = $address->getNVPArray();
     if (!empty($nvpArray)) {
         $payment->address = $address;
     }
     /* seller */
     $seller = Seller::getResponse($paymentResponse);
     $nvpArray = $seller->getNVPArray();
     if (!empty($nvpArray)) {
         $payment->seller = $seller;
     }
     /* error */
     $error = PaymentError::getResponse($paymentResponse);
     $nvpArray = $error->getNVPArray();
     if (!empty($nvpArray)) {
         $payment->error = $error;
     }
     return $payment;
 }