jenkins-bot has submitted this change and it was merged.
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, 62 insertions(+), 31 deletions(-)
Approvals:
Awight: Looks good to me, approved
jenkins-bot: Verified
diff --git a/astropay_gateway/astropay.adapter.php
b/astropay_gateway/astropay.adapter.php
index 132757c..e650a8f 100644
--- a/astropay_gateway/astropay.adapter.php
+++ b/astropay_gateway/astropay.adapter.php
@@ -250,9 +250,9 @@
// Name: ASTROPAY TESTING
// Birthdate: 04/03/1984
$this->payment_submethods['test'] = array(
- 'bankcode' => 'TE',
- 'label' => 'GNB',
- 'group' => 'cc',
+ 'bankcode' => 'TE',
+ 'label' => 'GNB',
+ 'group' => 'cc',
'validation' => array(),
'keys' => array(),
);
@@ -260,91 +260,96 @@
// Visa
$this->payment_submethods['visa'] = array(
- 'bankcode' => 'VI',
- 'label' => 'Visa',
- 'group' => 'cc',
+ 'bankcode' => 'VI',
+ 'label' => 'Visa',
+ 'group' => 'cc',
'validation' => array(),
'keys' => array(),
);
// MasterCard
$this->payment_submethods['mc'] = array(
- 'bankcode' => 'MC',
- 'label' => 'MasterCard',
- 'group' => 'cc',
+ 'bankcode' => 'MC',
+ 'label' => 'MasterCard',
+ 'group' => 'cc',
'validation' => array(),
'keys' => array(),
);
// American Express
$this->payment_submethods['amex'] = array(
- 'bankcode' => 'AE',
- 'label' => 'American Express',
- 'group' => 'cc',
+ 'bankcode' => 'AE',
+ 'label' => 'American Express',
+ 'group' => 'cc',
'validation' => array(),
'keys' => array(),
);
// Visa Debit
$this->payment_submethods['visa_debit'] = array(
- 'paymentproductid' => 'VD',
- 'label' => 'Visa Debit',
- 'group' => 'cc',
+ 'bankcode' => 'VD',
+ 'label' => 'Visa Debit',
+ 'group' => 'cc',
'validation' => array(),
'keys' => array(),
);
// MasterCard debit
$this->payment_submethods['mc_debit'] = array(
- 'bankcode' => 'MD',
- 'label' => 'Mastercard Debit',
- 'group' => 'cc',
+ 'bankcode' => 'MD',
+ 'label' => 'Mastercard Debit',
+ 'group' => 'cc',
'validation' => array(),
'keys' => array(),
);
// Elo (Brazil-only)
$this->payment_submethods['elo'] = array(
- 'bankcode' => 'EL',
- 'label' => 'Elo',
- 'group' => 'cc',
+ 'bankcode' => 'EL',
+ 'label' => 'Elo',
+ 'group' => 'cc',
'validation' => array(),
'keys' => array(),
);
// Diners Club
$this->payment_submethods['dc'] = array(
- 'bankcode' => 'DC',
- 'label' => 'Diners Club',
- 'group' => 'cc',
+ 'bankcode' => 'DC',
+ 'label' => 'Diners Club',
+ 'group' => 'cc',
'validation' => array(),
'keys' => array(),
);
// Hipercard
$this->payment_submethods['hiper'] = array(
- 'bankcode' => 'HI',
- 'label' => 'Hipercard',
- 'group' => 'cc',
+ 'bankcode' => 'HI',
+ 'label' => 'Hipercard',
+ 'group' => 'cc',
'validation' => array(),
'keys' => array(),
);
// Argencard
$this->payment_submethods['argen'] = array(
- 'bankcode' => 'AG',
- 'label' => 'Argencard',
- 'group' => 'cc',
+ 'bankcode' => 'AG',
+ 'label' => 'Argencard',
+ 'group' => 'cc',
'validation' => array(),
'keys' => array(),
);
}
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;
}
/**
@@ -396,6 +401,20 @@
$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 ) {
+ throw new UnexpectedValueException( "No unique payment
submethod defined for payment method $method and bank code $bank." );
+ }
+ $keys = array_keys( $candidates );
+ $this->unstaged_data['payment_submethod'] = $keys[0];
+ }
+
static function getCurrencies() {
$currencies = array(
'ARS', // Argentinian peso
diff --git a/tests/Adapter/Astropay/AstropayTest.php
b/tests/Adapter/Astropay/AstropayTest.php
index b5f7211..c9898c5 100644
--- a/tests/Adapter/Astropay/AstropayTest.php
+++ b/tests/Adapter/Astropay/AstropayTest.php
@@ -261,4 +261,16 @@
$status = $gateway->getFinalStatus();
$this->assertEquals( FinalStatus::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: merged
Gerrit-Change-Id: I2f3a6869c77a712904e678af21e416071d1a696c
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits