Example #1
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;
 }