当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Contribute_BAO_Contribution_Utils::_fillCommonParams方法代码示例

本文整理汇总了PHP中CRM_Contribute_BAO_Contribution_Utils::_fillCommonParams方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_Contribution_Utils::_fillCommonParams方法的具体用法?PHP CRM_Contribute_BAO_Contribution_Utils::_fillCommonParams怎么用?PHP CRM_Contribute_BAO_Contribution_Utils::_fillCommonParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Contribute_BAO_Contribution_Utils的用法示例。


在下文中一共展示了CRM_Contribute_BAO_Contribution_Utils::_fillCommonParams方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: formatAPIParams

 /**
  * @param array $apiParams
  * @param $mapper
  * @param string $type
  * @param bool $category
  *
  * @return array
  */
 public static function formatAPIParams($apiParams, $mapper, $type = 'paypal', $category = TRUE)
 {
     $type = strtolower($type);
     if (!in_array($type, array('paypal', 'csv'))) {
         // return the params as is
         return $apiParams;
     }
     $params = $transaction = array();
     if ($type == 'paypal') {
         foreach ($apiParams as $detail => $val) {
             if (isset($mapper['contact'][$detail])) {
                 $params[$mapper['contact'][$detail]] = $val;
             } elseif (isset($mapper['location'][$detail])) {
                 $params['address'][1][$mapper['location'][$detail]] = $val;
             } elseif (isset($mapper['transaction'][$detail])) {
                 switch ($detail) {
                     case 'l_period2':
                         // Sadly, PayPal seems to send two distinct data elements in a single field,
                         // so we break them out here.  This is somewhat ugly and tragic.
                         $freqUnits = array('D' => 'day', 'W' => 'week', 'M' => 'month', 'Y' => 'year');
                         list($frequency_interval, $frequency_unit) = explode(' ', $val);
                         $transaction['frequency_interval'] = $frequency_interval;
                         $transaction['frequency_unit'] = $freqUnits[$frequency_unit];
                         break;
                     case 'subscriptiondate':
                     case 'timestamp':
                         // PayPal dates are in  ISO-8601 format.  We need a format that
                         // MySQL likes
                         $unix_timestamp = strtotime($val);
                         $transaction[$mapper['transaction'][$detail]] = date('YmdHis', $unix_timestamp);
                         break;
                     case 'note':
                     case 'custom':
                     case 'l_number0':
                         if ($val) {
                             $val = "[PayPal_field:{$detail}] {$val}";
                             $transaction[$mapper['transaction'][$detail]] = !empty($transaction[$mapper['transaction'][$detail]]) ? $transaction[$mapper['transaction'][$detail]] . " <br/> " . $val : $val;
                         }
                         break;
                     default:
                         $transaction[$mapper['transaction'][$detail]] = $val;
                 }
             }
         }
         if (!empty($transaction) && $category) {
             $params['transaction'] = $transaction;
         } else {
             $params += $transaction;
         }
         CRM_Contribute_BAO_Contribution_Utils::_fillCommonParams($params, $type);
         return $params;
     }
     if ($type == 'csv') {
         $header = $apiParams['header'];
         unset($apiParams['header']);
         foreach ($apiParams as $key => $val) {
             if (isset($mapper['contact'][$header[$key]])) {
                 $params[$mapper['contact'][$header[$key]]] = $val;
             } elseif (isset($mapper['location'][$header[$key]])) {
                 $params['address'][1][$mapper['location'][$header[$key]]] = $val;
             } elseif (isset($mapper['transaction'][$header[$key]])) {
                 $transaction[$mapper['transaction'][$header[$key]]] = $val;
             } else {
                 $params[$header[$key]] = $val;
             }
         }
         if (!empty($transaction) && $category) {
             $params['transaction'] = $transaction;
         } else {
             $params += $transaction;
         }
         CRM_Contribute_BAO_Contribution_Utils::_fillCommonParams($params, $type);
         return $params;
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:83,代码来源:ContributionProcessor.php

示例2: formatAPIParams

 /**
  * @param array $apiParams
  * @param $mapper
  * @param string $type
  * @param bool $category
  *
  * @return array
  */
 public static function formatAPIParams($apiParams, $mapper, $type = 'paypal', $category = TRUE)
 {
     $type = strtolower($type);
     if (!in_array($type, array('paypal', 'google', 'csv'))) {
         // return the params as is
         return $apiParams;
     }
     $params = $transaction = array();
     if ($type == 'paypal') {
         foreach ($apiParams as $detail => $val) {
             if (isset($mapper['contact'][$detail])) {
                 $params[$mapper['contact'][$detail]] = $val;
             } elseif (isset($mapper['location'][$detail])) {
                 $params['address'][1][$mapper['location'][$detail]] = $val;
             } elseif (isset($mapper['transaction'][$detail])) {
                 switch ($detail) {
                     case 'l_period2':
                         // Sadly, PayPal seems to send two distinct data elements in a single field,
                         // so we break them out here.  This is somewhat ugly and tragic.
                         $freqUnits = array('D' => 'day', 'W' => 'week', 'M' => 'month', 'Y' => 'year');
                         list($frequency_interval, $frequency_unit) = explode(' ', $val);
                         $transaction['frequency_interval'] = $frequency_interval;
                         $transaction['frequency_unit'] = $freqUnits[$frequency_unit];
                         break;
                     case 'subscriptiondate':
                     case 'timestamp':
                         // PayPal dates are in  ISO-8601 format.  We need a format that
                         // MySQL likes
                         $unix_timestamp = strtotime($val);
                         $transaction[$mapper['transaction'][$detail]] = date('YmdHis', $unix_timestamp);
                         break;
                     case 'note':
                     case 'custom':
                     case 'l_number0':
                         if ($val) {
                             $val = "[PayPal_field:{$detail}] {$val}";
                             $transaction[$mapper['transaction'][$detail]] = !empty($transaction[$mapper['transaction'][$detail]]) ? $transaction[$mapper['transaction'][$detail]] . " <br/> " . $val : $val;
                         }
                         break;
                     default:
                         $transaction[$mapper['transaction'][$detail]] = $val;
                 }
             }
         }
         if (!empty($transaction) && $category) {
             $params['transaction'] = $transaction;
         } else {
             $params += $transaction;
         }
         CRM_Contribute_BAO_Contribution_Utils::_fillCommonParams($params, $type);
         return $params;
     }
     if ($type == 'csv') {
         $header = $apiParams['header'];
         unset($apiParams['header']);
         foreach ($apiParams as $key => $val) {
             if (isset($mapper['contact'][$header[$key]])) {
                 $params[$mapper['contact'][$header[$key]]] = $val;
             } elseif (isset($mapper['location'][$header[$key]])) {
                 $params['address'][1][$mapper['location'][$header[$key]]] = $val;
             } elseif (isset($mapper['transaction'][$header[$key]])) {
                 $transaction[$mapper['transaction'][$header[$key]]] = $val;
             } else {
                 $params[$header[$key]] = $val;
             }
         }
         if (!empty($transaction) && $category) {
             $params['transaction'] = $transaction;
         } else {
             $params += $transaction;
         }
         CRM_Contribute_BAO_Contribution_Utils::_fillCommonParams($params, $type);
         return $params;
     }
     if ($type == 'google') {
         // return if response smell invalid
         if (!array_key_exists('risk-information-notification', $apiParams[1][$apiParams[0]]['notifications'])) {
             return FALSE;
         }
         $riskInfo =& $apiParams[1][$apiParams[0]]['notifications']['risk-information-notification'];
         if (array_key_exists('new-order-notification', $apiParams[1][$apiParams[0]]['notifications'])) {
             $newOrder =& $apiParams[1][$apiParams[0]]['notifications']['new-order-notification'];
         }
         if ($riskInfo['google-order-number']['VALUE'] == $apiParams[2]['google-order-number']['VALUE']) {
             foreach ($riskInfo['risk-information']['billing-address'] as $field => $info) {
                 if (!empty($mapper['location'][$field])) {
                     $params['address'][1][$mapper['location'][$field]] = $info['VALUE'];
                 } elseif (!empty($mapper['contact'][$field])) {
                     if ($newOrder && !empty($newOrder['buyer-billing-address']['structured-name'])) {
                         foreach ($newOrder['buyer-billing-address']['structured-name'] as $namePart => $nameValue) {
                             $params[$mapper['contact'][$namePart]] = $nameValue['VALUE'];
                         }
//.........这里部分代码省略.........
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:101,代码来源:ContributionProcessor.php


注:本文中的CRM_Contribute_BAO_Contribution_Utils::_fillCommonParams方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。