/** * @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; }
public function init($map = null, $prefix = '') { if ($map != null) { $mapKeyName = $prefix . 'fundingPlanId'; if ($map != null && array_key_exists($mapKeyName, $map)) { $this->fundingPlanId = $map[$mapKeyName]; } if (PPUtils::array_match_key($map, $prefix . "fundingAmount.")) { $newPrefix = $prefix . "fundingAmount."; $this->fundingAmount = new CurrencyType(); $this->fundingAmount->init($map, $newPrefix); } if (PPUtils::array_match_key($map, $prefix . "backupFundingSource.")) { $newPrefix = $prefix . "backupFundingSource."; $this->backupFundingSource = new FundingSource(); $this->backupFundingSource->init($map, $newPrefix); } if (PPUtils::array_match_key($map, $prefix . "senderFees.")) { $newPrefix = $prefix . "senderFees."; $this->senderFees = new CurrencyType(); $this->senderFees->init($map, $newPrefix); } if (PPUtils::array_match_key($map, $prefix . "currencyConversion.")) { $newPrefix = $prefix . "currencyConversion."; $this->currencyConversion = new CurrencyConversion(); $this->currencyConversion->init($map, $newPrefix); } $i = 0; while (true) { if (PPUtils::array_match_key($map, $prefix . "charge({$i})")) { $newPrefix = $prefix . "charge({$i})."; $this->charge[$i] = new FundingPlanCharge(); $this->charge[$i]->init($map, $newPrefix); } else { break; } $i++; } } }