[MediaWiki-commits] [Gerrit] wikimedia...SmashPig[master]: Clean up antifraud queue usage
Ejegg has uploaded a new change for review. https://gerrit.wikimedia.org/r/310670 Change subject: Clean up antifraud queue usage .. Clean up antifraud queue usage No more KeyedOpaqueStorableObject or mirroring to ActiveMQ, just push an array straight to Redis Bug: T131273 Change-Id: Ib06f946899c2217f52b6277233b679dca95f69c6 --- D CrmLink/Messages/DonationInterfaceAntifraud.php A CrmLink/Messages/DonationInterfaceAntifraudFactory.php M PaymentProviders/Adyen/Jobs/ProcessCaptureRequestJob.php M PaymentProviders/Adyen/Tests/config_test.yaml M PaymentProviders/Adyen/Tests/phpunit/CaptureJobTest.php M SmashPig.yaml M Tests/MessageTest.php 7 files changed, 75 insertions(+), 87 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/SmashPig refs/changes/70/310670/1 diff --git a/CrmLink/Messages/DonationInterfaceAntifraud.php b/CrmLink/Messages/DonationInterfaceAntifraud.php deleted file mode 100644 index f462300..000 --- a/CrmLink/Messages/DonationInterfaceAntifraud.php +++ /dev/null @@ -1,44 +0,0 @@ -risk_score = $riskScore; - $obj->score_breakdown = $scoreBreakdown; - $obj->validation_action = $validationAction; - - $obj->contribution_tracking_id = $message['contribution_tracking_id']; - $obj->date = $message['date']; - $obj->gateway = $message['gateway']; - $obj->gateway_txn_id = $message['gateway_txn_id']; - $obj->order_id = $message['order_id']; - $obj->payment_method = $message['payment_method']; - // no 'server' available - $obj->user_ip = $message['user_ip']; - - return $obj; - } -} diff --git a/CrmLink/Messages/DonationInterfaceAntifraudFactory.php b/CrmLink/Messages/DonationInterfaceAntifraudFactory.php new file mode 100644 index 000..dc8c7f5 --- /dev/null +++ b/CrmLink/Messages/DonationInterfaceAntifraudFactory.php @@ -0,0 +1,38 @@ + $riskScore, + 'score_breakdown' => $scoreBreakdown, + 'validation_action' => $validationAction, + ); + + $keysToCopy = array( + 'contribution_tracking_id', + 'date', + 'gateway', + 'gateway_txn_id', + 'order_id', + 'payment_method', + 'user_ip' + // no 'server' available + ); + + foreach( $keysToCopy as $key ) { + $antifraud[$key] = $donationMessage[$key]; + } + + return $antifraud; + } +} diff --git a/PaymentProviders/Adyen/Jobs/ProcessCaptureRequestJob.php b/PaymentProviders/Adyen/Jobs/ProcessCaptureRequestJob.php index 8a06d51..fb39f08 100644 --- a/PaymentProviders/Adyen/Jobs/ProcessCaptureRequestJob.php +++ b/PaymentProviders/Adyen/Jobs/ProcessCaptureRequestJob.php @@ -5,7 +5,7 @@ use SmashPig\Core\Jobs\RunnableJob; use SmashPig\Core\Logging\Logger; use SmashPig\Core\Logging\TaggedLogger; -use SmashPig\CrmLink\Messages\DonationInterfaceAntifraud; +use SmashPig\CrmLink\Messages\DonationInterfaceAntifraudFactory; use SmashPig\PaymentProviders\Adyen\AdyenPaymentsInterface; use SmashPig\PaymentProviders\Adyen\ExpatriatedMessages\Authorisation; @@ -189,11 +189,13 @@ } protected function sendAntifraudMessage( $dbMessage, $riskScore, $scoreBreakdown, $action ) { - $antifraudMessage = DonationInterfaceAntifraud::factory( + $antifraudMessage = DonationInterfaceAntifraudFactory::create( $dbMessage, $riskScore, $scoreBreakdown, $action ); $this->logger->debug( "Sending antifraud message with risk score $riskScore and action $action." ); - Configuration::getDefaultConfig()->object( 'data-store/antifraud' )->push( $antifraudMessage ); + Configuration::getDefaultConfig() + ->object( 'data-store/payments-antifraud' ) + ->push( $antifraudMessage ); } /** diff --git a/PaymentProviders/Adyen/Tests/config_test.yaml b/PaymentProviders/Adyen/Tests/config_test.yaml index 40185fa..2be830d 100644 --- a/PaymentProviders/Adyen/Tests/config_test.yaml +++ b/PaymentProviders/Adyen/Tests/config_test.yaml @@ -1,8 +1,11 @@ adyen: data-store: -antifraud-stomp: -class: SmashPig\Tests\MockDataStore +payments-antifraud: +class: PHPQueue\Backend\PDO +constructor-parameters: +- +connection_string: 'sqlite::memory:' verified: class: PHPQueue\Backend\PDO diff --git a/PaymentProviders/Adyen/Tests/phpunit/CaptureJobTest.php b/PaymentProviders/Adyen/Tests/phpunit/CaptureJobTest.php index 8c1e270..e
[MediaWiki-commits] [Gerrit] wikimedia...SmashPig[master]: Clean up antifraud queue usage
Ejegg has submitted this change and it was merged. Change subject: Clean up antifraud queue usage .. Clean up antifraud queue usage No more KeyedOpaqueStorableObject or mirroring to ActiveMQ, just push an array straight to Redis Bug: T131273 Change-Id: Ib06f946899c2217f52b6277233b679dca95f69c6 --- D CrmLink/Messages/DonationInterfaceAntifraud.php A CrmLink/Messages/DonationInterfaceAntifraudFactory.php M PaymentProviders/Adyen/Jobs/ProcessCaptureRequestJob.php M PaymentProviders/Adyen/Tests/config_test.yaml M PaymentProviders/Adyen/Tests/phpunit/CaptureJobTest.php M SmashPig.yaml M Tests/MessageTest.php 7 files changed, 75 insertions(+), 87 deletions(-) Approvals: Awight: Looks good to me, approved jenkins-bot: Verified diff --git a/CrmLink/Messages/DonationInterfaceAntifraud.php b/CrmLink/Messages/DonationInterfaceAntifraud.php deleted file mode 100644 index f462300..000 --- a/CrmLink/Messages/DonationInterfaceAntifraud.php +++ /dev/null @@ -1,44 +0,0 @@ -risk_score = $riskScore; - $obj->score_breakdown = $scoreBreakdown; - $obj->validation_action = $validationAction; - - $obj->contribution_tracking_id = $message['contribution_tracking_id']; - $obj->date = $message['date']; - $obj->gateway = $message['gateway']; - $obj->gateway_txn_id = $message['gateway_txn_id']; - $obj->order_id = $message['order_id']; - $obj->payment_method = $message['payment_method']; - // no 'server' available - $obj->user_ip = $message['user_ip']; - - return $obj; - } -} diff --git a/CrmLink/Messages/DonationInterfaceAntifraudFactory.php b/CrmLink/Messages/DonationInterfaceAntifraudFactory.php new file mode 100644 index 000..dc8c7f5 --- /dev/null +++ b/CrmLink/Messages/DonationInterfaceAntifraudFactory.php @@ -0,0 +1,38 @@ + $riskScore, + 'score_breakdown' => $scoreBreakdown, + 'validation_action' => $validationAction, + ); + + $keysToCopy = array( + 'contribution_tracking_id', + 'date', + 'gateway', + 'gateway_txn_id', + 'order_id', + 'payment_method', + 'user_ip' + // no 'server' available + ); + + foreach( $keysToCopy as $key ) { + $antifraud[$key] = $donationMessage[$key]; + } + + return $antifraud; + } +} diff --git a/PaymentProviders/Adyen/Jobs/ProcessCaptureRequestJob.php b/PaymentProviders/Adyen/Jobs/ProcessCaptureRequestJob.php index 8a06d51..fb39f08 100644 --- a/PaymentProviders/Adyen/Jobs/ProcessCaptureRequestJob.php +++ b/PaymentProviders/Adyen/Jobs/ProcessCaptureRequestJob.php @@ -5,7 +5,7 @@ use SmashPig\Core\Jobs\RunnableJob; use SmashPig\Core\Logging\Logger; use SmashPig\Core\Logging\TaggedLogger; -use SmashPig\CrmLink\Messages\DonationInterfaceAntifraud; +use SmashPig\CrmLink\Messages\DonationInterfaceAntifraudFactory; use SmashPig\PaymentProviders\Adyen\AdyenPaymentsInterface; use SmashPig\PaymentProviders\Adyen\ExpatriatedMessages\Authorisation; @@ -189,11 +189,13 @@ } protected function sendAntifraudMessage( $dbMessage, $riskScore, $scoreBreakdown, $action ) { - $antifraudMessage = DonationInterfaceAntifraud::factory( + $antifraudMessage = DonationInterfaceAntifraudFactory::create( $dbMessage, $riskScore, $scoreBreakdown, $action ); $this->logger->debug( "Sending antifraud message with risk score $riskScore and action $action." ); - Configuration::getDefaultConfig()->object( 'data-store/antifraud' )->push( $antifraudMessage ); + Configuration::getDefaultConfig() + ->object( 'data-store/payments-antifraud' ) + ->push( $antifraudMessage ); } /** diff --git a/PaymentProviders/Adyen/Tests/config_test.yaml b/PaymentProviders/Adyen/Tests/config_test.yaml index 40185fa..2be830d 100644 --- a/PaymentProviders/Adyen/Tests/config_test.yaml +++ b/PaymentProviders/Adyen/Tests/config_test.yaml @@ -1,8 +1,11 @@ adyen: data-store: -antifraud-stomp: -class: SmashPig\Tests\MockDataStore +payments-antifraud: +class: PHPQueue\Backend\PDO +constructor-parameters: +- +connection_string: 'sqlite::memory:' verified: class: PHPQueue\Backend\PDO diff --git a/PaymentProviders/Adyen/Tests/phpunit/CaptureJobTest.php b/PaymentProviders/Adyen/Tests/phpunit/CaptureJobTest.php index 8c1e270..efcabbc 100644 --- a/PaymentProviders/Adyen/Tests/phpunit/Capt