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;
 }
Example #2
0
 /**
  * @return array
  */
 public function getNVPRequest()
 {
     $request = $this->collection->getAllValues();
     /* payment */
     foreach ($this->payments as $index => $payment) {
         foreach ($payment->getNVPArray() as $key => $value) {
             if (is_array($value)) {
                 // payment item is array and has to start with L_
                 foreach ($value as $itemIndex => $item) {
                     foreach ($item as $k => $v) {
                         $request['L_PAYMENTREQUEST_' . $index . '_' . $k . $itemIndex] = $v;
                     }
                 }
             } else {
                 $request['PAYMENTREQUEST_' . $index . '_' . $key] = $value;
             }
         }
     }
     /* billing agreement */
     foreach ($this->billingAgreement as $index => $billingAgreement) {
         foreach ($billingAgreement->getNVPArray() as $key => $value) {
             $request['L_' . $key . $index] = $value;
         }
     }
     /* shipping options */
     foreach ($this->shipping as $index => $shipping) {
         foreach ($shipping->getNVPArray() as $key => $value) {
             $request['L_' . $key . $index] = $value;
         }
     }
     /* buyer and funding */
     if ($this->buyer != null) {
         $request = array_merge($request, $this->buyer->getNVPArray());
     }
     if ($this->funding != null) {
         $request = array_merge($request, $this->funding->getNVPArray());
     }
     return $request;
 }
Example #3
0
 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;
 }
 public function getNVPRequest()
 {
     $request = $this->collection->getAllValues();
     /* payment */
     foreach ($this->payments as $index => $payment) {
         foreach ($payment->getNVPArray() as $key => $value) {
             if (is_array($value)) {
                 // payment item is array and has to start with L_
                 foreach ($value as $itemIndex => $item) {
                     foreach ($item as $k => $v) {
                         $request['L_PAYMENTREQUEST_' . $index . '_' . $k . $itemIndex] = $v;
                     }
                 }
             } else {
                 $request['PAYMENTREQUEST_' . $index . '_' . $key] = $value;
             }
         }
     }
     /* user selected options */
     if ($this->userOptions != null) {
         $request = array_merge($request, $this->userOptions->getNVPArray());
     }
     return $request;
 }
Example #5
0
 public function getNVPArray()
 {
     return $this->collection->getAllValues();
 }
 public function getNVPRequest()
 {
     return $this->collection->getAllValues();
 }
Example #7
0
 /**
  * Calling object needs to prepend 'PAYMENTREQUEST_n_', if value is an
  * array then needs to prepend 'L_PAYMENTREQUEST_n_...m'
  *
  * @return array
  */
 public function getNVPArray()
 {
     /* response */
     if (!$this->request) {
         $response = $this->collection->getAllValues();
         if ($this->address != null) {
             $response = array_merge($response, $this->address->getNVPArray());
         }
         if ($this->seller != null) {
             $response = array_merge($response, $this->seller->getNVPArray());
         }
         foreach ($this->items as $index => $value) {
             $response[$index] = $value->getNVPArray();
         }
         return $response;
     }
     /* request */
     $response = array();
     /* total amount of all items */
     $itemAmount = 0;
     /* total tax of all items */
     $taxAmount = 0;
     /* items in this payment */
     $items = array();
     /* add amount and tax from all items and create keys for nvp */
     foreach ($this->items as $index => $item) {
         foreach ($item->getNVPArray() as $key => $value) {
             if ($key == 'AMT') {
                 $itemAmount += $value;
             }
             if ($key == 'TAXAMT') {
                 $taxAmount += $value;
             }
             $items[$index][$key] = $value;
         }
     }
     if ($itemAmount > 0) {
         $response['ITEMAMT'] = $itemAmount;
     }
     if ($taxAmount > 0) {
         $response['TAXAMT'] = $taxAmount;
     }
     /* add everything to the final amount - AMT */
     $response['AMT'] = $itemAmount + $taxAmount;
     if (isset($this->nvpRequest['SHIPPINGAMT'])) {
         $respone['AMT'] += $this->nvpRequest['SHIPPINGAMT'];
         if (isset($this->nvpRequest['SHIPDISCAMT'])) {
             $respone['AMT'] -= $this->nvpRequest['SHIPDISCAMT'];
         }
     }
     if (isset($this->nvpRequest['INSURANCEAMT'])) {
         $response['AMT'] += $this->nvpRequest['INSURANCEAMT'];
     }
     if (isset($this->nvpRequest['HANDLINGAMT'])) {
         $response['AMT'] += $this->nvpRequest['HANDLINGAMT'];
     }
     /* add items as an array */
     $response['items'] = $items;
     /* merge nvp string with the values autogenarated from items */
     return array_merge($this->collection->getAllValues(), $response);
 }