/** * Queue a message with the banner history ID sent on the URL, the * contribution tracking ID from DonationData, and some additional data. */ protected function queueAssociationOfIds() { $this->logger->debug('BannerHistoryLogIdProcessor::queueAssociationOfIds(): will ' . 'push to banner-history queue if required info is available.'); $bannerHistoryId = WmfFramework::getRequestValue(self::BANNER_HISTORY_LOG_ID_PARAM, null); // Campaigns may not have banner history enabled. For now, at least, // bow out silently if no banner history ID was sent. if (!$bannerHistoryId) { return; } $contributionTrackingId = $this->gatewayAdapter->getData_Unstaged_Escaped('contribution_tracking_id'); if (!$contributionTrackingId) { $this->logger->info('No contribution tracking ID for ' . 'banner-history queue ' . $bannerHistoryId . '.'); return; } $data = array('freeform' => true, 'banner_history_id' => $bannerHistoryId, 'contribution_tracking_id' => $contributionTrackingId); $this->logger->info('Pushing to banner-history queue.'); DonationQueue::instance()->push($data, 'banner-history'); }
/** * Harvest a varname from its source - post, get, maybe even session eventually. * @TODO: Provide a way that gateways can override default behavior here for individual keys. * @param string $var The incoming var name we need to get a value for * @return mixed The final value of the var, or null if we don't actually have it. */ protected function sourceHarvest($var) { if ($this->gateway->isBatchProcessor()) { return null; } $ret = WmfFramework::getRequestValue($var, null); return $ret; }
/** * buildOrderIDSources: Uses the 'alt_locations' array in the order id * metadata, to build an array of all possible candidates for order_id. * This will also weed out candidates that do not meet the * gateway-specific data constraints for that field, and are therefore * invalid. * * @TODO: Data Item Class. There should be a class that keeps track of * the metadata for every field we use (everything that currently comes * back from DonationData), that can be overridden per gateway. Revisit * this in a more universal way when that time comes. */ public function buildOrderIDSources() { static $built = false; if ($built && isset($this->order_id_candidates)) { //once per request is plenty return; } //pull all order ids and variants from all their usual locations $locations = array('request' => 'order_id', 'session' => array('Donor' => 'order_id')); $alt_locations = $this->getOrderIDMeta('alt_locations'); if ($alt_locations && is_array($alt_locations)) { foreach ($alt_locations as $var => $key) { $locations[$var] = $key; } } if ($this->isBatchProcessor()) { // Can't use request or session from here. $locations = array_diff_key($locations, array_flip(array('request', 'session'))); } //Now pull all the locations and populate the candidate array. $oid_candidates = array(); foreach ($locations as $var => $key) { switch ($var) { case "request": $value = WmfFramework::getRequestValue($key, ''); if ($value !== '') { $oid_candidates[$var] = $value; } break; case "session": if (is_array($key)) { foreach ($key as $subkey => $subvalue) { $parentVal = WmfFramework::getSessionValue($subkey); if (is_array($parentVal) && array_key_exists($subvalue, $parentVal)) { $oid_candidates['session' . $subkey . $subvalue] = $parentVal[$subvalue]; } } } else { $val = WmfFramework::getSessionValue($key); if (!is_null($val)) { $oid_candidates[$var] = $val; } } break; default: if (!is_array($key) && array_key_exists($key, ${$var})) { //simple case first. This is a direct key in $var. $oid_candidates[$var] = ${$var}[$key]; } if (is_array($key)) { foreach ($key as $subkey => $subvalue) { if (array_key_exists($subkey, ${$var}) && array_key_exists($subvalue, ${$var}[$subkey])) { $oid_candidates[$var . $subkey . $subvalue] = ${$var}[$subkey][$subvalue]; } } } break; } } //unset every invalid candidate foreach ($oid_candidates as $source => $value) { if (empty($value) || !$this->validateDataConstraintsMet('order_id', $value)) { unset($oid_candidates[$source]); } } $this->order_id_candidates = $oid_candidates; $built = true; }