jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/381490 )
Change subject: Prefer 'invoice_id' to 'order_id' for importing invoice_id
......................................................................
Prefer 'invoice_id' to 'order_id' for importing invoice_id
Bug: T171349
Change-Id: I9e58c6012abb7a3e32b721e0c694d187aa8576c6
---
M sites/all/modules/queue2civicrm/tests/includes/Message.php
M sites/all/modules/queue2civicrm/tests/phpunit/DonationQueueTest.php
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
3 files changed, 61 insertions(+), 8 deletions(-)
Approvals:
XenoRyet: Looks good to me, approved
jenkins-bot: Verified
diff --git a/sites/all/modules/queue2civicrm/tests/includes/Message.php
b/sites/all/modules/queue2civicrm/tests/includes/Message.php
index cb64acf..170c158 100644
--- a/sites/all/modules/queue2civicrm/tests/includes/Message.php
+++ b/sites/all/modules/queue2civicrm/tests/includes/Message.php
@@ -82,11 +82,13 @@
function __construct( $values = array() ) {
$this->loadDefaults( "donation" );
+ $ct_id = mt_rand();
- parent::__construct( array(
+ parent::__construct( $values + array(
$this->txn_id_key => mt_rand(),
- 'order_id' => mt_rand(),
- ) + $values );
+ 'order_id' => "$ct_id.1",
+ 'contribution_tracking_id' => $ct_id,
+ ) );
}
function getGateway() {
diff --git
a/sites/all/modules/queue2civicrm/tests/phpunit/DonationQueueTest.php
b/sites/all/modules/queue2civicrm/tests/phpunit/DonationQueueTest.php
index 6059718..35dd678 100644
--- a/sites/all/modules/queue2civicrm/tests/phpunit/DonationQueueTest.php
+++ b/sites/all/modules/queue2civicrm/tests/phpunit/DonationQueueTest.php
@@ -106,6 +106,53 @@
}
/**
+ * If 'invoice_id' is in the message, don't stuff that field with
order_id
+ */
+ public function testDonationInvoiceId() {
+ $message = new TransactionMessage(
+ array( 'invoice_id' => mt_rand() )
+ );
+
+ exchange_rate_cache_set( 'USD', $message->get( 'date' ), 1 );
+ exchange_rate_cache_set( $message->get( 'currency' ),
$message->get( 'date' ), 3 );
+
+ $this->queueConsumer->processMessage( $message->getBody() );
+
+ $campaignField = wmf_civicrm_get_custom_field_name( 'campaign'
);
+
+ $expected = array(
+ 'contact_type' => 'Individual',
+ 'sort_name' => 'laast, firrst',
+ 'display_name' => 'firrst laast',
+ 'first_name' => 'firrst',
+ 'last_name' => 'laast',
+ 'currency' => 'USD',
+ 'total_amount' => '2857.02',
+ 'fee_amount' => '0.00',
+ 'net_amount' => '2857.02',
+ 'trxn_id' => 'GLOBALCOLLECT ' .
$message->getGatewayTxnId(),
+ 'contribution_source' => 'PLN 952.34',
+ 'financial_type' => 'Cash',
+ 'contribution_status' => 'Completed',
+ 'payment_instrument' => 'Credit Card: Visa',
+ 'invoice_id' => $message->get( 'invoice_id' ),
+ $campaignField => 'Benefactor Gift',
+ );
+ $returnFields = array_keys( $expected );
+
+ $contribution = civicrm_api3(
+ 'Contribution',
+ 'getsingle',
+ array(
+ wmf_civicrm_get_custom_field_name(
'gateway_txn_id' ) => $message->getGatewayTxnId(),
+ 'return' => $returnFields
+ )
+ );
+
+ $this->assertArraySubset( $expected, $contribution );
+ }
+
+ /**
* Process an ordinary (one-time) donation message with an UTF campaign.
*/
public function testDonationWithUTFCampaignOption() {
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index 8888087..a838866 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -356,11 +356,15 @@
}
// Store the identifier we generated on payments
- if ( !empty( $msg['order_id'] ) ) {
- $contribution['invoice_id'] = $msg['order_id'];
- // The invoice_id column has a unique constraint
- if ( $msg['recurring'] ) {
- $contribution['invoice_id'] .= '|recur-' .
UtcDate::getUtcTimestamp();
+ $invoice_fields = array( 'invoice_id', 'order_id' );
+ foreach ( $invoice_fields as $invoice_field ) {
+ if ( !empty( $msg[$invoice_field] ) ) {
+ $contribution['invoice_id'] = $msg[$invoice_field];
+ // The invoice_id column has a unique constraint
+ if ( $msg['recurring'] ) {
+ $contribution['invoice_id'] .= '|recur-' .
UtcDate::getUtcTimestamp();
+ }
+ break;
}
}
--
To view, visit https://gerrit.wikimedia.org/r/381490
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9e58c6012abb7a3e32b721e0c694d187aa8576c6
Gerrit-PatchSet: 5
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: XenoRyet <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits