Ejegg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/207843
Change subject: Add limbo queue message before redirect
......................................................................
Add limbo queue message before redirect
Also set payment submethod from bank code
TODO: update with new DonationQueue calls once I637bcba899 is done.
Bug: T90504
Change-Id: I2f3a6869c77a712904e678af21e416071d1a696c
---
M astropay_gateway/astropay.adapter.php
M tests/Adapter/Astropay/AstropayTest.php
2 files changed, 32 insertions(+), 2 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/43/207843/1
diff --git a/astropay_gateway/astropay.adapter.php
b/astropay_gateway/astropay.adapter.php
index 807eda5..7751899 100644
--- a/astropay_gateway/astropay.adapter.php
+++ b/astropay_gateway/astropay.adapter.php
@@ -286,7 +286,7 @@
// Visa Debit
$this->payment_submethods['visa_debit'] = array(
- 'paymentproductid' => 'VD',
+ 'bankcode' => 'VD',
'label' => 'Visa Debit',
'group' => 'cc',
'validation' => array(),
@@ -340,10 +340,15 @@
}
function doPayment() {
- return PaymentResult::fromResults(
+ $result = PaymentResult::fromResults(
$this->do_transaction( 'NewInvoice' ),
$this->getFinalStatus()
);
+ if ( $result->getRedirect() ) {
+ $this->unstage_payment_submethod();
+ $this->doLimboStompTransaction();
+ }
+ return $result;
}
/**
@@ -395,6 +400,19 @@
$this->staged_data['donor_id'] = substr( $hashed, 0, 20 );
}
+ protected function unstage_payment_submethod() {
+ $method = $this->getData_Staged( 'payment_method' );
+ $bank = $this->getData_Staged( 'bank_code' );
+ $filter = function( $submethod ) use ( $method, $bank ) {
+ return $submethod['group'] === $method &&
$submethod['bankcode'] === $bank;
+ };
+ $candidates = array_filter( $this->payment_submethods, $filter
);
+ if ( count( $candidates ) === 1 ) {
+ $keys = array_keys( $candidates );
+ $this->unstaged_data['payment_submethod'] = $keys[0];
+ }
+ }
+
function getResponseStatus( $response ) {
if ( $response === NULL ) {
return false;
diff --git a/tests/Adapter/Astropay/AstropayTest.php
b/tests/Adapter/Astropay/AstropayTest.php
index a0e66e8..08d1e53 100644
--- a/tests/Adapter/Astropay/AstropayTest.php
+++ b/tests/Adapter/Astropay/AstropayTest.php
@@ -275,4 +275,16 @@
$this->assertNull( $result );
$this->assertEquals( 'failed', $status );
}
+
+ function testUnstagePaymentSubmethod() {
+ $init = $this->getDonorTestData( 'BR' );
+ $init['payment_method'] = 'cc';
+ $init['bank_code'] = 'VD';
+ $gateway = $this->getFreshGatewayObject( $init );
+
+ $gateway->doPayment();
+
+ $submethod = $gateway->getData_Unstaged_Escaped(
'payment_submethod' );
+ $this->assertEquals( 'visa_debit', $submethod, 'Not setting
payment submethod in doPayment' );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/207843
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2f3a6869c77a712904e678af21e416071d1a696c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits