Ejegg has submitted this change and it was merged.

Change subject: More non-optimal fixes for the nearly-decomissioned wr1 script
......................................................................


More non-optimal fixes for the nearly-decomissioned wr1 script

The chargeback/refund mechanism was never updated to use the
real order ID after we stopped stuffing it in MERCHANTREFERENCE
on payments. This should correct the issue in the near term.
In the long term, we will stop parsing wr1 files completely
very soon.

Change-Id: Idf8812a7f0e77367e33c0d5b7466b17b7c426947
---
M sites/all/modules/globalcollect_audit/globalcollect_audit.module
1 file changed, 33 insertions(+), 21 deletions(-)

Approvals:
  Ejegg: Looks good to me, approved



diff --git a/sites/all/modules/globalcollect_audit/globalcollect_audit.module 
b/sites/all/modules/globalcollect_audit/globalcollect_audit.module
index 07e87fb..fc0d547 100644
--- a/sites/all/modules/globalcollect_audit/globalcollect_audit.module
+++ b/sites/all/modules/globalcollect_audit/globalcollect_audit.module
@@ -1029,27 +1029,39 @@
 function globalcollect_audit_mark_rfd_cbk( $missing ){
        globalcollect_audit_echo('Marking refunds and chargebacks');
        $count = 0;
-       foreach ( $missing as $index => $wr1 ){
-               if ( wr1_is_negative_txn( $wr1 ) ){
-                       $send_message = array(
-                               'gateway_refund_id' => 'RFD' . wr1_order_id( 
$wr1 ), //after intense deliberation, we don't actually care what this is at 
all.
-                               'gateway_parent_id' => wr1_order_id( $wr1 ), 
//gateway transaction ID
-                               'gross_currency' => wr1_currency( $wr1 ), 
//currency code
-                               'gross' => wr1_amount( $wr1 ) / 100, //amount
-                               'date' => wr1_date_to_timestamp( $wr1 ), 
//timestamp
-                               'gateway' => 'globalcollect', //lcase
-                               'gateway_account' => $wr1['gateway_account'], 
//from DI. ?
-                               'payment_method' => '', //Argh. Not telling 
you. 
-                               'payment_submethod' => '', //Still not telling 
you.
-                               'type' => wr1_get_negative_type( $wr1 ), 
//refund or chargeback
-                       );
-                       echo print_r( $send_message, true );
-                       globalcollect_audit_send_stomp( 'refund', $send_message 
);
-                       $count += 1;
-                       globalcollect_audit_echo('.');
-                       
-                       unset( $missing[$index] );
-               }
+       foreach ($missing as $index => $wr1) {
+    //get the real order ID.
+    $parents = 
globalcollect_audit_get_contributions_from_whatever_this_is(wr1_order_id($wr1));
+    $parent = null;
+    if (is_array($parents) && !empty($parents)) {
+      $parent = array_shift($parents);
+    }
+
+    if (!is_null($parent) || !array_key_exists('gateway_txn_id', $parent)) {
+      globalcollect_audit_log_error(__FUNCTION__ . ": Could not find parent 
(or any related) transaction for refund/chargeback, but that should be 
impossible to do here... " . wr1_order_id($wr1), 'MISSING_PARENT');
+    } else {
+      $real_oid = $parent['gateway_txn_id'];
+
+      if (wr1_is_negative_txn($wr1)) {
+        $send_message = array(
+          'gateway_refund_id' => 'RFD' . $real_oid, //after intense 
deliberation, we don't actually care what this is at all.
+          'gateway_parent_id' => $real_oid, //gateway transaction ID
+          'gross_currency' => wr1_currency($wr1), //currency code
+          'gross' => wr1_amount($wr1) / 100, //amount
+          'date' => wr1_date_to_timestamp($wr1), //timestamp
+          'gateway' => 'globalcollect', //lcase
+          'gateway_account' => $wr1['gateway_account'], //from DI. ?
+          'payment_method' => '', //Argh. Not telling you.
+          'payment_submethod' => '', //Still not telling you.
+          'type' => wr1_get_negative_type($wr1), //refund or chargeback
+        );
+        echo print_r($send_message, true);
+        globalcollect_audit_send_stomp('refund', $send_message);
+        $count += 1;
+        globalcollect_audit_echo('.');
+      }
+      unset($missing[$index]); //only unset if we killed it
+    }
        }
        globalcollect_audit_results_ball( 'refunds/chargebacks', $count );
        return $missing;

-- 
To view, visit https://gerrit.wikimedia.org/r/184540
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Idf8812a7f0e77367e33c0d5b7466b17b7c426947
Gerrit-PatchSet: 2
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Katie Horn <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to