Ejegg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/236204
Change subject: WIP move subscription cancel into its own script
......................................................................
WIP move subscription cancel into its own script
Bug: T110917
Change-Id: Ief113d6ab10732e1325b44acbe26197cd5ac0184
---
A globalcollect_gateway/scripts/cancelSubscriptions.php
M globalcollect_gateway/scripts/refund.php
2 files changed, 56 insertions(+), 15 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/04/236204/1
diff --git a/globalcollect_gateway/scripts/cancelSubscriptions.php
b/globalcollect_gateway/scripts/cancelSubscriptions.php
new file mode 100644
index 0000000..db7a603
--- /dev/null
+++ b/globalcollect_gateway/scripts/cancelSubscriptions.php
@@ -0,0 +1,55 @@
+<?php
+
+$IP = getenv( 'MW_INSTALL_PATH' );
+if ( $IP === false ) {
+ $IP = __DIR__ . '/../../../..';
+}
+
+//If you get errors on this next line, set (and export) your MW_INSTALL_PATH
var.
+require_once( "$IP/maintenance/Maintenance.php" );
+
+// Cancel recurring payment orders
+// Input should be a file listing order IDs, one per line
+class GlobalCollectCancelSubscriptionMaintenance extends Maintenance {
+ public function __construct() {
+ parent::__construct();
+
+ $this->addOption( 'file', 'Order ID filename',
+ true, true, 'f' );
+ }
+
+ public function execute() {
+ global $wgGlobalCollectGatewayEnableCustomFilters;
+
+ // don't run fraud checks
+ $wgGlobalCollectGatewayEnableCustomFilters = false;
+
+ $filename = $this->getOption( 'file' );
+ if( !( $file = fopen( $filename, 'r' ) ) ){
+ $this->error( 'Could not find order ID file: ' .
$filename, true );
+ }
+ while ( ( $oid = fgets( $file ) ) !== false ) {
+ $gateway_opts = array(
+ 'batch_mode' => true,
+ 'external_data' => array(
+ 'order_id' => $oid,
+ ),
+ );
+
+ $this->output( "Cancelling subscription $oid\n" );
+ $adapter = new GlobalCollectAdapter( $gateway_opts );
+
+ $result = $adapter->cancelSubscription();
+
+ if ( $result->isFailed() ) {
+ $this->error( "Failed cancelling subscription
$oid" );
+ } else {
+ $this->output( "Successfully cancelled
subscription $oid\n" );
+ }
+ }
+ fclose( $file );
+ }
+}
+
+$maintClass = 'GlobalCollectCancelSubscriptionMaintenance';
+require_once RUN_MAINTENANCE_IF_MAIN;
diff --git a/globalcollect_gateway/scripts/refund.php
b/globalcollect_gateway/scripts/refund.php
index 04e17db..ae0c0c8 100644
--- a/globalcollect_gateway/scripts/refund.php
+++ b/globalcollect_gateway/scripts/refund.php
@@ -17,8 +17,6 @@
$this->addOption( 'file', 'Read refund detail in from a file',
true, true, 'f' );
- $this->addOption( 'unsubscribe', 'Cancel the subscription this
charge is a part of',
- false, false );
}
public function execute() {
@@ -27,12 +25,10 @@
// don't run fraud checks for refunds
$wgGlobalCollectGatewayEnableCustomFilters = false;
- $isUnsubscribing = $this->getOption( 'unsubscribe' );
-
$filename = $this->getOption( 'file' );
if( !( $file = fopen( $filename, 'r' ) ) ){
$this->error( 'Could not find refund file: ' .
$filename, true );
- }
+ }
while ( $refund = fgetcsv( $file ) ) {
if ( count( $refund ) !== 7 ) {
$this->error( 'Refund lines must have exactly 7
fields', true );
@@ -63,16 +59,6 @@
$this->error( "Failed refunding transaction
$oid" );
} else {
$this->output( "Successfully refunded
transaction $oid\n" );
- }
-
- if ( $isUnsubscribing ) {
- $result = $adapter->cancelSubscription();
-
- if ( $result->isFailed() ) {
- $this->error( "Failed cancelling
subscription $oid" );
- } else {
- $this->output( "Successfully cancelled
subscription $oid\n" );
- }
}
}
fclose( $file );
--
To view, visit https://gerrit.wikimedia.org/r/236204
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ief113d6ab10732e1325b44acbe26197cd5ac0184
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