Ejegg has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/349253 )
Change subject: Delete old PP-specific normalization
......................................................................
Delete old PP-specific normalization
Now happens upstream
Change-Id: I311643d40cb3503f95abb18291fbd871091c333e
---
M sites/all/modules/queue2civicrm/recurring/RecurringQueueConsumer.php
1 file changed, 0 insertions(+), 173 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm
refs/changes/53/349253/1
diff --git
a/sites/all/modules/queue2civicrm/recurring/RecurringQueueConsumer.php
b/sites/all/modules/queue2civicrm/recurring/RecurringQueueConsumer.php
index b37b404..851e40c 100644
--- a/sites/all/modules/queue2civicrm/recurring/RecurringQueueConsumer.php
+++ b/sites/all/modules/queue2civicrm/recurring/RecurringQueueConsumer.php
@@ -84,11 +84,6 @@
// should not require special normalization
} else if ( !isset( $msg[ 'contribution_tracking_id' ]) ) {
$msg_normalized[ 'contribution_tracking_id' ] =
recurring_get_contribution_tracking_id( $msg );
- // TODO: remove this after deploying audit and IPN
updates to do message normalization there
- if ( isset( $msg['payer_email'] ) ) {
- // This is an old-school non-normalized PayPal
message.
- $msg = $this->normalizePaypalMessage( $msg );
- }
} else {
$msg['contribution_tracking_update'] = false;
}
@@ -104,174 +99,6 @@
$msg = wmf_civicrm_normalize_msg( $msg );
return $msg;
- }
-
- /**
- * Normalize raw PayPal message
- *
- * It is possible that we'll get a raw message from PayPal. If that is
the
- * case, this will convert the raw PayPal message to our normalized
format.
- *
- * This is large and unwieldy.
- *
- * FIXME: move this normalization into the paypal listener
- *
- * @param $msg
- * @return array
- */
- protected function normalizePaypalMessage( $msg ) {
- $msg_normalized = array();
-
- if ( isset( $msg['payment_date'] ) ) {
- $msg_normalized['date'] = strtotime(
$msg['payment_date'] );
- }
-
- // the subscription id
- $msg_normalized[ 'subscr_id' ] = $msg[ 'subscr_id' ];
- $msg_normalized[ 'txn_type' ] = $msg[ 'txn_type' ];
- $msg_normalized[ 'email' ] = $msg[ 'payer_email' ];
-
- // Premium info
- if ( isset( $msg[ 'option_selection1' ] ) && !is_numeric( $msg[
'option_selection1' ] ) ) {
- $msg_normalized[ 'size' ] = $msg[ 'option_selection1' ];
- $msg_normalized[ 'premium_language' ] = $msg[
'option_selection2' ];
- }
-
- // Contact info
- if ( $msg[ 'txn_type' ] == 'subscr_signup' || $msg[ 'txn_type'
] == 'subscr_payment' || $msg[ 'txn_type' ] == 'subscr_modify' ) {
- $msg_normalized[ 'first_name' ] = $msg[ 'first_name' ];
- $msg_normalized[ 'middle_name' ] = '';
- $msg_normalized[ 'last_name' ] = $msg[ 'last_name' ];
-
- if ( isset( $msg['address_street'] ) ) {
- $split = explode("\n", str_replace("\r", '',
$msg[ 'address_street' ]));
- $msg_normalized[ 'street_address' ] = $split[0];
- if ( count( $split ) > 1 ) {
- $msg_normalized[
'supplemental_address_1' ] = $split[1];
- }
- $msg_normalized[ 'city' ] = $msg[
'address_city' ];
- $msg_normalized[ 'state_province' ] = $msg[
'address_state' ];
- $msg_normalized[ 'country' ] = $msg[
'address_country_code' ];
- $msg_normalized[ 'postal_code' ] = $msg[
'address_zip' ];
-
- // Shipping info (address same as above since
PayPal only passes 1 address)
- $split = explode(" ", $msg[ 'address_name' ]);
- $msg_normalized[ 'last_name_2' ] =
array_pop($split);
- $msg_normalized[ 'first_name_2' ] = implode("
", $split);
- $split = explode("\n", str_replace("\r", '',
$msg[ 'address_street' ]));
- $msg_normalized[ 'street_address_2' ] =
$split[0];
- if ( count( $split ) > 1 ) {
- $msg_normalized[
'supplemental_address_2' ] = $split[1];
- }
- } elseif ( isset( $msg['residence_country'] ) ) {
- $msg_normalized['country'] =
$msg['residence_country'];
- }
- }
-
- // payment-specific message handling
- if ( $msg[ 'txn_type' ] == 'subscr_payment' ) {
- // default to not update contribution tracking data
- $msg_normalized[ 'contribution_tracking_update' ] =
false;
-
- // get the database connection to the tracking table
- $dbs = wmf_civicrm_get_dbs();
- $dbs->push( 'donations' );
- $query = "SELECT * FROM {contribution_tracking} WHERE
id = :id";
- $tracking_data = db_query( $query, array( ':id' =>
$msg[ 'custom' ] ) )->fetchAssoc();
- if ( $tracking_data ) {
- // if we don't have a contribution id in the
tracking data, we need to update
- if ( !$tracking_data[ 'contribution_id' ] ||
!is_numeric( $tracking_data[ 'contribution_id' ] ) ) {
- $msg_normalized[
'contribution_tracking_update' ] = true;
- $msg_normalized[ 'optout' ] =
$tracking_data[ 'optout' ];
- $msg_normalized[ 'anonymous' ] =
$tracking_data[ 'anonymous' ];
- $msg_normalized[ 'comment' ] =
$tracking_data[ 'note' ];
- }
- } else {
- watchdog( 'recurring', "There is no
contribution tracking id associated with this message.", array(),
WATCHDOG_NOTICE );
- }
-
- $msg_normalized[ 'gateway_txn_id' ] = $msg[ 'txn_id' ];
- $msg_normalized[ 'currency' ] = $msg[ 'mc_currency' ];
- $msg_normalized[ 'gross' ] = $msg[ 'mc_gross' ];
- $msg_normalized[ 'fee' ] = $msg[ 'mc_fee' ];
- $msg_normalized[ 'gross' ] = $msg[ 'mc_gross' ];
- $msg_normalized[ 'net' ] = $msg_normalized[ 'gross' ] -
$msg_normalized[ 'fee' ];
- $msg_normalized[ 'payment_date' ] = strtotime( $msg[
'payment_date' ] );
- } else {
-
- // break the period out for civicrm
- if( isset( $msg[ 'period3' ] ) ) {
- // map paypal period unit to civicrm period
units
- $period_map = array(
- 'm' => 'month',
- 'd' => 'day',
- 'w' => 'week',
- 'y' => 'year',
- );
-
- $period = explode( " ", $msg[ 'period3' ] );
- $msg_normalized[ 'frequency_interval' ] =
$period[0];
- $msg_normalized[ 'frequency_unit' ] =
$period_map[ strtolower( $period[1] ) ];
- }
-
- if ( isset( $msg[ 'recur_times' ] ) ) {
- $msg_normalized[ 'installments' ] = $msg[
'recur_times' ];
- } else {
- // forever
- $msg_normalized[ 'installments' ] = 0;
- }
-
- if ( isset( $msg[ 'amount3' ] ) ) {
- $msg_normalized[ 'gross' ] = $msg[ 'amount3' ];
- } elseif ( isset( $msg[ 'mc_amount3' ] ) ) {
- $msg_normalized[ 'gross' ] = $msg[ 'mc_amount3'
];
- }
-
- if ( isset( $msg['mc_currency'] ) ) {
- $msg_normalized[ 'currency' ] = $msg[
'mc_currency' ];
- }
-
- if ( isset( $msg[ 'subscr_date' ] ) ) {
- if ( $msg[ 'txn_type' ] == 'subscr_signup' ) {
- $msg_normalized[ 'create_date' ] =
strtotime( $msg[ 'subscr_date' ] );
- $msg_normalized[ 'start_date' ] =
strtotime( $msg[ 'subscr_date' ] );
- } elseif( $msg[ 'txn_type' ] == 'subscr_cancel'
) {
- $msg_normalized[ 'cancel_date' ] =
strtotime( $msg[ 'subscr_date' ] );
- }
- if ( !isset( $msg_normalized['date'] ) ) {
- $msg_normalized['date'] = strtotime(
$msg['subscr_date'] );
- }
- }
-
- if ( $msg[ 'txn_type' ] == 'subscr_modify' ) {
- $msg_normalized[ 'modified_date' ] = $msg[
'subscr_effective' ];
- }
-
- if ( $msg[ 'txn_type' ] == 'subscr_failed' ) {
- $recur_record = wmf_civicrm_get_recur_record(
$msg[ 'subscr_id' ] );
- $msg_normalized[ 'failure_count' ] =
$recur_record->failure_count + 1;
- if ( isset( $msg[ 'retry_at' ] )) {
- $msg_normalized[ 'failure_retry_date' ]
= strtotime( $msg[ 'retry_at' ] );
- } elseif( isset( $msg[ 'failure_retry_date' ]
)) {
- $msg_normalized[ 'failure_retry_date' ]
= strtotime( $msg[ 'failure_retry_date' ] );
- }
- }
- }
-
- $msg_normalized[ 'gateway' ] = ( !empty( $msg['gateway'] ) ?
$msg['gateway'] : 'paypal' );
-
- if ( !isset( $msg_normalized['date'] ) ) {
- $msg_normalized['date'] = time();
- }
-
- // FIXME: so dirty.
- foreach ( $msg as $key => $value ) {
- if ( strpos( $key, "source_" ) === 0 ) {
- $msg_normalized[$key] = $value;
- }
- }
-
- return $msg_normalized;
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/349253
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I311643d40cb3503f95abb18291fbd871091c333e
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits