public function readRequestVariables() { $input = $this->readXmlData(); if (Gpf_Settings::get(Recurly_Config::RESEND_URL) != "") { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, Gpf_Settings::get(Recurly_Config::RESEND_URL)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 60); //curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $input); curl_exec($ch); /* $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, Gpf_Settings::get(Recurly_Config::RESEND_URL)); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST); curl_exec($ch); */ } $this->debug("Input get: " . $input); try { $xml = new SimpleXMLElement($input); } catch (Exception $e) { $this->setPaymentStatus("Failed"); $this->debug('Wrong XML format!'); return false; } // read last tag to find out what kind of request this is, e.g. </new_subscription_notification> $status = strrpos($input,"</"); $status = substr($input,$status+2,strlen($input)-1); $status = substr($status,0,strrpos($status,">")); $this->setType($status); if ($this->getType() == self::NEWPAYMENT) { $totalcost_name = "amount_in_cents"; $this->setData1((string)$xml->{"transaction"}->{"invoice_number"}); } else { $totalcost_name = "total_amount_in_cents"; $this->setProductID((string)$xml->{"transaction"}->{"plan_code"}); } $this->setTransactionID((string)$xml->{"account"}->{"account_code"}); $this->setTotalCost((string)$xml->{"transaction"}->{$totalcost_name}/100)*(((string)$xml->{"transaction"}->{"quantity"})?(string)$xml->{"transaction"}->{"quantity"}:1); // get original Affiliate $status = array(Pap_Common_Constants::STATUS_APPROVED, Pap_Common_Constants::STATUS_PENDING); $types = array(Pap_Common_Constants::TYPE_SALE, Pap_Common_Constants::TYPE_ACTION, Pap_Common_Constants::TYPE_LEAD); $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Pap_Db_Table_Transactions::getInstance()); $select->from->add(Pap_Db_Table_Transactions::getName()); $select->where->add(Pap_Db_Table_Transactions::ORDER_ID, "=", $this->getOrderID()); $select->where->add(Pap_Db_Table_Transactions::R_TYPE, "IN", $types); $select->where->add(Pap_Db_Table_Transactions::R_STATUS, "IN", $status); $transaction = new Pap_Common_Transaction(); $transaction->fillFromSelect($select); if (($transaction->getUserId() == null) OR ($transaction->getUserId() == "")) { $this->debug('No affiliate found for order ID: '.$this->getOrderID()); } else { $this->setAccountId($transaction->getAccountId()); $this->setAffiliateID($transaction->getUserId()); $this->setProductID($transaction->getProductId()); $this->setCampaignId($transaction->getCampaignId()); } }