Merge pull request #2326 from eileenmcnaughton/CRM-14069
[civicrm-core.git] / CRM / Core / Payment / GoogleIPN.php
index 0e08f0c49464920a019482b53a2f714f7f40dcdf..4dd6ed4241d3ce9f5fe951d0eff7ef1dd64757eb 100644 (file)
 
 
 define('GOOGLE_DEBUG_PP', 0);
+
+/**
+ * Class CRM_Core_Payment_GoogleIPN
+ */
 class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
 
   /**
@@ -53,6 +57,14 @@ class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
    */
   protected $_mode = NULL;
 
+  /**
+   * @param $name
+   * @param $type
+   * @param $object
+   * @param bool $abort
+   *
+   * @return mixed
+   */
   static function retrieve($name, $type, $object, $abort = TRUE) {
     $value = CRM_Utils_Array::value($name, $object);
     if ($abort && $value === NULL) {
@@ -77,7 +89,9 @@ class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
    *
    * @param string $mode the mode of operation: live or test
    *
-   * @return void
+   * @param $paymentProcessor
+   *
+   * @return \CRM_Core_Payment_GoogleIPN
    */
   function __construct($mode, &$paymentProcessor) {
     parent::__construct();
@@ -89,11 +103,12 @@ class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
   /**
    * The function gets called when a new order takes place.
    *
-   * @param xml   $dataRoot    response send by google in xml format
+   * @param xml $dataRoot response send by google in xml format
    * @param array $privateData contains the name value pair of <merchant-private-data>
    *
-   * @return void
+   * @param $component
    *
+   * @return void
    */
   function newOrderNotify($dataRoot, $privateData, $component) {
     $ids = $input = $params = array();
@@ -168,6 +183,8 @@ class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
           $contribution->invoice_id = $input['invoice'];
           $contribution->total_amount = $dataRoot['order-total']['VALUE'];
           $contribution->contribution_status_id = 2;
+          $contribution->campaign_id = $objects['contribution']->campaign_id;
+
           $objects['contribution'] = $contribution;
         }
         $transaction->commit();
@@ -209,10 +226,10 @@ class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
              * lets make use of it by passing the eventID/membershipTypeID to next level.
              * And change trxn_id to google-order-number before finishing db update */
 
-      if (CRM_Utils_Array::value('event', $ids)) {
+      if (!empty($ids['event'])) {
         $contribution->trxn_id = $ids['event'] . CRM_Core_DAO::VALUE_SEPARATOR . $ids['participant'];
       }
-      elseif (CRM_Utils_Array::value('membership', $ids)) {
+      elseif (!empty($ids['membership'])) {
         $contribution->trxn_id = $ids['membership'][0] . CRM_Core_DAO::VALUE_SEPARATOR . $ids['related_contact'] . CRM_Core_DAO::VALUE_SEPARATOR . $ids['onbehalf_dupe_alert'];
       }
     }
@@ -227,11 +244,13 @@ class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
   /**
    * The function gets called when the state(CHARGED, CANCELLED..) changes for an order
    *
-   * @param string $status      status of the transaction send by google
-   * @param array  $privateData contains the name value pair of <merchant-private-data>
+   * @param string $status status of the transaction send by google
+   * @param $dataRoot
+   * @param array $privateData contains the name value pair of <merchant-private-data>
    *
-   * @return void
+   * @param $component
    *
+   * @return void
    */
   function orderStateChange($status, $dataRoot, $privateData, $component) {
     $input = $objects = $ids = array();
@@ -321,6 +340,11 @@ class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
     $this->completeRecur($input, $ids, $objects);
   }
 
+  /**
+   * @param $input
+   * @param $ids
+   * @param $objects
+   */
   function completeRecur($input, $ids, $objects) {
     if ($ids['contributionRecur']) {
       $recur               = &$objects['contributionRecur'];
@@ -374,6 +398,9 @@ WHERE  contribution_recur_id = {$ids['contributionRecur']}
    *
    * @param string $mode the mode of operation: live or test
    *
+   * @param $component
+   * @param $paymentProcessor
+   *
    * @return object
    * @static
    */
@@ -406,11 +433,13 @@ WHERE  contribution_recur_id = {$ids['contributionRecur']}
   /**
    * The function returns the component(Event/Contribute..), given the google-order-no and merchant-private-data
    *
-   * @param xml     $xml_response   response send by google in xml format
-   * @param array   $privateData    contains the name value pair of <merchant-private-data>
-   * @param int     $orderNo        <order-total> send by google
-   * @param string  $root           root of xml-response
+   * @param array $privateData contains the name value pair of <merchant-private-data>
+   * @param int $orderNo <order-total> send by google
+   * @param string $root root of xml-response
    *
+   * @param $response
+   * @param $serial
+   * @internal param \xml $xml_response response send by google in xml format
    * @return array context of this call (test, module, payment processor id)
    * @static
    */
@@ -620,6 +649,13 @@ WHERE  contribution_recur_id = {$ids['contributionRecur']}
     }
   }
 
+  /**
+   * @param $input
+   * @param $ids
+   * @param $dataRoot
+   *
+   * @return bool
+   */
   function getInput(&$input, &$ids, $dataRoot) {
     if (!$this->getBillingID($ids)) {
       return FALSE;