Ejegg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/281697
Change subject: Actually random dummy fiscal number for MX
......................................................................
Actually random dummy fiscal number for MX
Hack now has tests... should it take up residence in a gateway
specific staging helper?
Bug: T131793
Change-Id: If5e664dc1fd57d956c7c405c52a3efad4eb84d68
---
M gateway_common/FiscalNumber.php
M tests/Adapter/Astropay/AstropayTest.php
M tests/DonationInterfaceTestCase.php
3 files changed, 28 insertions(+), 3 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/97/281697/1
diff --git a/gateway_common/FiscalNumber.php b/gateway_common/FiscalNumber.php
index 4796f02..8fe4826 100644
--- a/gateway_common/FiscalNumber.php
+++ b/gateway_common/FiscalNumber.php
@@ -10,10 +10,11 @@
$unstagedData['country'] === 'MX' &&
$adapter->getIdentifier() === 'astropay'
) {
- // Not validated, but currently required by the
AstroPay API
- // Needs to be 13 digits
+ // Not validated, but currently required by the
AstroPay API.
+ // Needs to be 13 digits, and random so they
don't blacklist
+ // a repeated one.
// TODO: Remove this when they fix it
- $stagedData['fiscal_number'] = '1111222233334';
+ $stagedData['fiscal_number'] = mt_rand(1.0e+12,
1.0e+13);
}
} else {
$stagedData['fiscal_number'] = preg_replace(
'/[^a-zA-Z0-9]/', '', $unstagedData['fiscal_number'] );
diff --git a/tests/Adapter/Astropay/AstropayTest.php
b/tests/Adapter/Astropay/AstropayTest.php
index 583d257..fdff7d2 100644
--- a/tests/Adapter/Astropay/AstropayTest.php
+++ b/tests/Adapter/Astropay/AstropayTest.php
@@ -579,4 +579,17 @@
'Should show a currency code error for trying to use
CLP in BR'
);
}
+
+ function testDummyFiscalNumber() {
+ $init = $this->getDonorTestData( 'MX' );
+ $gateway = $this->getFreshGatewayObject( $init );
+ $gateway->doPayment();
+
+ parse_str( $gateway->curled[0], $firstParams );
+ $fiscalNumber = $firstParams['x_cpf'];
+ $this->assertEquals(
+ 13, strlen( $fiscalNumber ),
+ 'Fake fiscal number should be 13 digits'
+ );
+ }
}
diff --git a/tests/DonationInterfaceTestCase.php
b/tests/DonationInterfaceTestCase.php
index df2c9e3..4fca50f 100644
--- a/tests/DonationInterfaceTestCase.php
+++ b/tests/DonationInterfaceTestCase.php
@@ -267,6 +267,17 @@
'language' => 'pt',
'email' => '[email protected]'
),
+ 'MX' => array (
+ 'city' => 'Tuxtla GutiƩrrez',
+ 'state' => 'CHP',
+ 'currency_code' => 'MXN',
+ 'street' => 'Calle Falso 123',
+ 'fname' => 'Nombre',
+ 'lname' => 'Apellido',
+ 'email' => '[email protected]',
+ 'amount' => '155',
+ 'language' => 'es',
+ ),
);
//default to US
if ( $country === '' ) {
--
To view, visit https://gerrit.wikimedia.org/r/281697
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If5e664dc1fd57d956c7c405c52a3efad4eb84d68
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