INFRA-132 - Batch #8
[civicrm-core.git] / CRM / Core / Payment / GoogleIPN.php
index 2d2a59ef22174d4b0d0d84c4ffc84d98d0bf7c45..16c5d6633cf5e3eafb738dec24a35ddf4dd1b29b 100644 (file)
@@ -33,7 +33,6 @@
   */
 
 
-
 define('GOOGLE_DEBUG_PP', 0);
 
 /**
@@ -46,7 +45,6 @@ class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
    * pattern and cache the instance in this variable
    *
    * @var object
-   * @static
    */
   static private $_singleton = NULL;
 
@@ -123,9 +121,9 @@ class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
 
     $ids['contributionRecur'] = $ids['contributionPage'] = NULL;
     if ($input['component'] == "event") {
-      $ids['event']       = self::retrieve('eventID', 'Integer', $privateData, TRUE);
+      $ids['event'] = self::retrieve('eventID', 'Integer', $privateData, TRUE);
       $ids['participant'] = self::retrieve('participantID', 'Integer', $privateData, TRUE);
-      $ids['membership']  = NULL;
+      $ids['membership'] = NULL;
     }
     else {
       $ids['membership'] = self::retrieve('membershipID', 'Integer', $privateData, FALSE);
@@ -175,7 +173,7 @@ class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
           // create a contribution and then get it processed
           $contribution = new CRM_Contribute_DAO_Contribution();
           $contribution->contact_id = $ids['contact'];
-          $contribution->financial_type_id  = $objects['contributionType']->id;
+          $contribution->financial_type_id = $objects['contributionType']->id;
           $contribution->contribution_page_id = $objects['contribution']->contribution_page_id;
           $contribution->contribution_recur_id = $ids['contributionRecur'];
           $contribution->receive_date = date('YmdHis');
@@ -299,11 +297,14 @@ class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
       $ids['onbehalf_dupe_alert'] = NULL;
       if ($contribution->trxn_id) {
         list($ids['membership'], $ids['related_contact'], $ids['onbehalf_dupe_alert']) = explode(CRM_Core_DAO::VALUE_SEPARATOR,
-        $contribution->trxn_id
+          $contribution->trxn_id
         );
       }
       foreach (array(
-        'membership', 'related_contact', 'onbehalf_dupe_alert') as $fld) {
+                 'membership',
+                 'related_contact',
+                 'onbehalf_dupe_alert',
+               ) as $fld) {
         if (!is_numeric($ids[$fld])) {
           unset($ids[$fld]);
         }
@@ -328,11 +329,11 @@ class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
       return $this->failed($objects, $transaction);
     }
 
-    $input['amount']     = $contribution->total_amount;
+    $input['amount'] = $contribution->total_amount;
     $input['fee_amount'] = NULL;
     $input['net_amount'] = NULL;
-    $input['trxn_id']    = $ids['contributionRecur'] ? $serial : $dataRoot['google-order-number']['VALUE'];
-    $input['is_test']    = $contribution->is_test;
+    $input['trxn_id'] = $ids['contributionRecur'] ? $serial : $dataRoot['google-order-number']['VALUE'];
+    $input['is_test'] = $contribution->is_test;
 
     $recur = NULL;
     if ($ids['contributionRecur']) {
@@ -350,8 +351,8 @@ class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN {
    */
   public function completeRecur($input, $ids, $objects) {
     if ($ids['contributionRecur']) {
-      $recur               = &$objects['contributionRecur'];
-      $contributionCount   = CRM_Core_DAO::singleValueQuery("
+      $recur = &$objects['contributionRecur'];
+      $contributionCount = CRM_Core_DAO::singleValueQuery("
 SELECT count(*)
 FROM   civicrm_contribution
 WHERE  contribution_recur_id = {$ids['contributionRecur']}
@@ -408,7 +409,6 @@ WHERE  contribution_recur_id = {$ids['contributionRecur']}
    * @param $paymentProcessor
    *
    * @return object
-   * @static
    */
   public static function &singleton($mode, $component, &$paymentProcessor) {
     if (self::$_singleton === NULL) {
@@ -451,7 +451,6 @@ WHERE  contribution_recur_id = {$ids['contributionRecur']}
    * @internal param \xml $xml_response response send by google in xml format
    * @return array
    *   context of this call (test, module, payment processor id)
-   * @static
    */
   public function getContext($privateData, $orderNo, $root, $response, $serial) {
     $contributionID = CRM_Utils_Array::value('contributionID', $privateData);
@@ -492,8 +491,7 @@ WHERE  contribution_recur_id = {$ids['contributionRecur']}
         $ids['event'] = $privateData['eventID'];
       }
       else {
-        list($ids['event'], $ids['participant']) =
-          explode(CRM_Core_DAO::VALUE_SEPARATOR, $contribution->trxn_id);
+        list($ids['event'], $ids['participant']) = explode(CRM_Core_DAO::VALUE_SEPARATOR, $contribution->trxn_id);
       }
     }
 
@@ -518,7 +516,6 @@ WHERE  contribution_recur_id = {$ids['contributionRecur']}
   /**
    * This method is handles the response that will be invoked (from extern/googleNotify) every time
    * a notification or request is sent by the Google Server.
-   *
    */
   public static function main($xml_response) {
     require_once 'Google/library/googleresponse.php';
@@ -549,12 +546,13 @@ WHERE  contribution_recur_id = {$ids['contributionRecur']}
       $privateData = $data[$root]['shopping-cart']['merchant-private-data']['VALUE'];
     }
     if (empty($privateData) && array_key_exists('order-summary', $data[$root])
-        && array_key_exists('shopping-cart', $data[$root]['order-summary'])) {
+      && array_key_exists('shopping-cart', $data[$root]['order-summary'])
+    ) {
       $privateData = $data[$root]['order-summary']['shopping-cart']['merchant-private-data']['VALUE'];
     }
     $privateData = $privateData ? self::stringToArray($privateData) : '';
-    $orderNo     = $data[$root]['google-order-number']['VALUE'];
-    $serial      = $data[$root]['serial-number'];
+    $orderNo = $data[$root]['google-order-number']['VALUE'];
+    $serial = $data[$root]['serial-number'];
 
     // a dummy object to call get context and a parent function inside it.
     $ipn = new CRM_Core_Payment_GoogleIPN('live', $dummyProcessor);
@@ -586,13 +584,12 @@ WHERE  contribution_recur_id = {$ids['contributionRecur']}
       case "merchant-calculation-callback":
         break;
 
-      case "new-order-notification":{
+      case "new-order-notification":
         $response->SendAck($serial, FALSE);
         $ipn->newOrderNotify($data[$root], $privateData, $module);
         break;
-        }
 
-      case "order-state-change-notification":{
+      case "order-state-change-notification":
         $response->SendAck($serial, FALSE);
         $new_financial_state = $data[$root]['new-financial-order-state']['VALUE'];
         $new_fulfillment_order = $data[$root]['new-fulfillment-order-state']['VALUE'];
@@ -616,9 +613,8 @@ WHERE  contribution_recur_id = {$ids['contributionRecur']}
             break;
         }
         break;
-        }
 
-      case "authorization-amount-notification":{
+      case "authorization-amount-notification":
         $response->SendAck($serial, FALSE);
         $new_financial_state = $data[$root]['order-summary']['financial-order-state']['VALUE'];
         $new_fulfillment_order = $data[$root]['order-summary']['fulfillment-order-state']['VALUE'];
@@ -645,7 +641,6 @@ WHERE  contribution_recur_id = {$ids['contributionRecur']}
             break;
         }
         break;
-        }
 
       case "charge-amount-notification":
       case "chargeback-amount-notification":