Mwalker has submitted this change and it was merged.
Change subject: generalize some normalizations for recurring msgs
......................................................................
generalize some normalizations for recurring msgs
Change-Id: I3da844e5099fc6d7fc3d6d6e33c33540987265d5
---
M sites/all/modules/queue2civicrm/recurring/recurring.module
M sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
2 files changed, 22 insertions(+), 3 deletions(-)
Approvals:
Mwalker: Verified; Looks good to me, approved
diff --git a/sites/all/modules/queue2civicrm/recurring/recurring.module
b/sites/all/modules/queue2civicrm/recurring/recurring.module
index 1896a01..99e38a8 100644
--- a/sites/all/modules/queue2civicrm/recurring/recurring.module
+++ b/sites/all/modules/queue2civicrm/recurring/recurring.module
@@ -393,6 +393,7 @@
$dbs->push( 'civicrm' );
$result = db_insert( 'civicrm_contribution_recur' )->fields( array(
'contact_id' => $contact[ 'id' ],
+ 'currency' => $msg[ 'currency' ],
'amount' => $msg[ 'amount' ],
'frequency_unit' => $msg[ 'frequency_unit' ],
'frequency_interval' => $msg[ 'frequency_interval' ],
@@ -580,8 +581,10 @@
$msg = json_decode($msg->body, true);
}
- // we can safely assume we have a raw msg from paypal if
contribution_tracking_id isn't set
- if ( !isset( $msg[ 'contribution_tracking_id' ]) ) {
+ if ( $msg['gateway'] === 'amazon' ) {
+ // should not require special normalization
+ } else if ( !isset( $msg[ 'contribution_tracking_id' ]) ) {
+ // we can safely assume we have a raw msg from paypal if
contribution_tracking_id isn't set
$msg = recurring_normalize_paypal_msg( $msg );
} else {
$msg['contribution_tracking_update'] = false;
@@ -607,6 +610,8 @@
* case, this will convert the raw PayPal message to our normalized format.
*
* This is large and unwieldly.
+ *
+ * FIXME: move this normalization into the paypal listener
*
* @param $msg
* @return array
@@ -738,7 +743,7 @@
}
}
- $msg_normalized[ 'gateway' ] = ( strlen( $msg[ 'gateway' ] )) ? $msg[
'gateway' ] : 'paypal';
+ $msg_normalized[ 'gateway' ] = ( !empty( $msg['gateway'] ) ? $msg['gateway']
: 'paypal' );
$msg_normalized[ 'date' ] = $timestamp;
diff --git a/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
b/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
index 76141bd..9807e62 100644
--- a/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
@@ -589,6 +589,15 @@
$msg = json_decode($msg->body, true);
}
+ //FIXME: normalize *before* validation
+ if ( empty( $msg['original_currency'] ) and !empty( $msg['currency'] ) ) {
+ $msg['original_currency'] = $msg['currency'];
+ }
+
+ if ( empty( $msg['original_gross'] ) and !empty( $msg['gross'] ) ) {
+ $msg['original_gross'] = $msg['gross'];
+ }
+
$required = array(
'email',
'gross',
@@ -957,6 +966,11 @@
$msg['date'] = time();
}
+ if ( $msg['recurring'] and !isset( $msg['start_date'] ) ) {
+ $msg['start_date'] = $msg['date'];
+ $msg['create_date'] = $msg['date'];
+ }
+
if ( !empty( $msg['thankyou_date'] ) ) {
if ( !is_numeric( $msg['thankyou_date'] ) ) {
$unix_time = strtotime( $msg['thankyou_date'] );
--
To view, visit https://gerrit.wikimedia.org/r/62531
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3da844e5099fc6d7fc3d6d6e33c33540987265d5
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>
Gerrit-Reviewer: Katie Horn <[email protected]>
Gerrit-Reviewer: Mwalker <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits