예제 #1
0
 /**
  * Process PAY notification data from PayPal.
  * This method updates transaction record.
  *
  * @param array $result
  * @param string $url  The parameters of the component
  * @param bool $loadCertificate
  * @param Joomla\Registry\Registry $params  The parameters of the component
  *
  * @return null|array
  */
 protected function processPay(&$result, $url, $loadCertificate, &$params)
 {
     // Get raw post data and parse it.
     $rowPostString = file_get_contents("php://input");
     $string = new Prism\String($rowPostString);
     $rawPost = $string->parseNameValue();
     // DEBUG DATA
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . "_DEBUG_RESPONSE"), $this->debugType, $_POST) : null;
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . "_DEBUG_RESPONSE_INPUT"), $this->debugType, $rawPost) : null;
     $paypalIpn = new Prism\Payment\PayPal\Ipn($url, $rawPost);
     $paypalIpn->verify($loadCertificate);
     // DEBUG DATA
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . "_DEBUG_IPN_OBJECT"), $this->debugType, $paypalIpn) : null;
     if ($paypalIpn->isVerified()) {
         // Parse raw post transaction data.
         $rawPostTransaction = $paypalIpn->getTransactionData();
         if (!empty($rawPostTransaction)) {
             $_POST["transaction"] = $this->filterRawPostTransaction($rawPostTransaction);
         }
         JDEBUG ? $this->log->add(JText::_("PLG_CROWDFUNDINGPAYMENT_PAYPALADAPTIVE_DEBUG_FILTERED_RAW_POST"), $this->debugType, $_POST) : null;
         unset($rawPostTransaction);
         unset($rawPost);
         $preApprovalKey = Joomla\Utilities\ArrayHelper::getValue($_POST, "preapproval_key");
         // Validate transaction data
         $this->updateTransactionDataOnPay($_POST, $preApprovalKey);
     } else {
         // Log error
         $this->log->add(JText::_($this->textPrefix . "_ERROR_INVALID_TRANSACTION_DATA"), $this->debugType, array("error message" => $paypalIpn->getError(), "paypalIPN" => $paypalIpn, "_POST" => $_POST, "RAW POST" => $rawPost));
     }
     return $result;
 }