[MediaWiki-commits] [Gerrit] wikimedia...crm[deployment]: Add stripe import

2017-12-11 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/397716 )

Change subject: Add stripe import
..


Add stripe import

At this stage an exception is thrown if non-USD currencies are in use and 
utm_campaign column is respected
if set, ditto utm_medium with a default of MGEventEmail

There is a desire for currency support & I think that might be the case for 
another import too.
I also feel there is a desire for being able to set an import-wide default for 
a field. I've left these
out of this iteration.

Bug: T172423

Change-Id: I63a85f352caec1d695724a9b1dd1129f9a29781c
---
A sites/all/modules/offline2civicrm/StripeFile.php
M sites/all/modules/offline2civicrm/offline2civicrm.info
M sites/all/modules/offline2civicrm/offline2civicrm.module
A sites/all/modules/offline2civicrm/tests/StripeFileTest.php
A sites/all/modules/offline2civicrm/tests/data/stripe.csv
5 files changed, 184 insertions(+), 0 deletions(-)

Approvals:
  jenkins-bot: Verified
  Ejegg: Looks good to me, approved



diff --git a/sites/all/modules/offline2civicrm/StripeFile.php 
b/sites/all/modules/offline2civicrm/StripeFile.php
new file mode 100644
index 000..49b9f03
--- /dev/null
+++ b/sites/all/modules/offline2civicrm/StripeFile.php
@@ -0,0 +1,119 @@
+ 'gateway_txn_id',
+  'utm_source' => 'utm_source',
+  'utm_campaign' => 'utm_campaign',
+  'utm_medium' => 'utm_medium',
+  'Card Address Line1' => 'street_address',
+  'Card Address Line2' => 'supplemental_address_1',
+  'Card Address City' => 'city',
+  'Converted Amount' => 'gross',
+  'Amount' => 'original_gross',
+  'Created (UTC)' => 'date',
+  'Customer Email' => 'email',
+  'Converted Currency' => 'currency',
+  'Currency' => 'original_currency',
+  'Card Name' => 'full_name',
+  'Card Address State' => 'state_province',
+  'Card Address Zip' => 'postal_code',
+  'Card Address Country' => 'country',
+
+
+  //id,
+  //Description,
+  //Amount ,,
+  //Amount Refunded,
+  //Currency,
+  //Converted Amount Refunded,Fee,
+  //Tax,
+  //Converted Currency,
+  //Mode,
+  //Status,
+  //Statement Descriptor,
+  //Customer ID,
+  //Customer Description,,
+  //Captured,Card ID,
+  //Card Last4,
+  //Card Brand,
+  //Card Funding,
+  //Card Exp Month,
+  //Card Exp Year,
+  //Card Issue Country,
+  //Card Fingerprint,
+  //Card CVC Status,
+  //Card AVS Zip Status,
+  //Card AVS Line1 Status,
+  //Card Tokenization Method,
+  //Disputed Amount,
+  //Dispute Status,
+  //Dispute Reason,
+  //Dispute Date (UTC),
+  //Dispute Evidence Due (UTC)
+  //Invoice ID,
+  //Payment Source Type,
+  //Destination,
+  //Transfer,
+  //Transfer Group,
+  //event_id (metadata),
+  //event_name (metadata),
+  //order_number (metadata)
+);
+  }
+
+  protected function getDefaultValues() {
+return array_merge(parent::getDefaultValues(), array(
+'gateway' => 'stripe',
+'no_thank_you' => 'stripe',
+'payment_instrument' => 'Stripe',
+'payment_method' => 'Stripe',
+'utm_medium' => 'MGEventEmail',
+'contact_source' => 'Stripe import',
+  )
+);
+  }
+
+  /**
+   * Read a row and transform into normalized queue message form
+   *
+   * @param $data
+   *
+   * @return array queue message format
+   *
+   * @throws \EmptyRowException
+   * @throws \WmfException
+   */
+  protected function parseRow($data) {
+if (!empty($data['Converted Amount Refunded'])) {
+  throw new WmfException(WmfException::INVALID_MESSAGE, 'Refunds not 
currently handled. Please log a Phab if required');
+}
+return parent::parseRow($data);
+  }
+
+}
diff --git a/sites/all/modules/offline2civicrm/offline2civicrm.info 
b/sites/all/modules/offline2civicrm/offline2civicrm.info
index 4a49a4f..967c081 100644
--- a/sites/all/modules/offline2civicrm/offline2civicrm.info
+++ b/sites/all/modules/offline2civicrm/offline2civicrm.info
@@ -22,6 +22,7 @@
 files[] = PayPalChecksFile.php
 files[] = RefundFile.php
 files[] = SquareFile.php
+files[] = StripeFile.php
 files[] = TrilogyFile.php
 files[] = WmfImportFile.php
 files[] = WmfOrgImportFile.php
diff --git a/sites/all/modules/offline2civicrm/offline2civicrm.module 
b/sites/all/modules/offline2civicrm/offline2civicrm.module
index 71cb137..ed491c3 100644
--- a/sites/all/modules/offline2civicrm/offline2civicrm.module
+++ b/sites/all/modules/offline2civicrm/offline2civicrm.module
@@ -115,6 +115,7 @@
   'jpmorgan' => t('JP Morgan'),
   'paypal' => t('PayPal EFT'),
   'square' => t('Square'),
+  'stripe' => t('Stripe'),
   'trilogy' => t('Trilogy'),
 ),
   );
@@ -194,6 +195,11 @@
 case 'square':
   $importer = new SquareFile($file->uri);
   break;
+
+case 'stripe

[MediaWiki-commits] [Gerrit] wikimedia...crm[deployment]: Add stripe import

2017-12-11 Thread Ejegg (Code Review)
Ejegg has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/397716 )

Change subject: Add stripe import
..

Add stripe import

At this stage an exception is thrown if non-USD currencies are in use and 
utm_campaign column is respected
if set, ditto utm_medium with a default of MGEventEmail

There is a desire for currency support & I think that might be the case for 
another import too.
I also feel there is a desire for being able to set an import-wide default for 
a field. I've left these
out of this iteration.

Bug: T172423

Change-Id: I63a85f352caec1d695724a9b1dd1129f9a29781c
---
A sites/all/modules/offline2civicrm/StripeFile.php
M sites/all/modules/offline2civicrm/offline2civicrm.info
M sites/all/modules/offline2civicrm/offline2civicrm.module
A sites/all/modules/offline2civicrm/tests/StripeFileTest.php
A sites/all/modules/offline2civicrm/tests/data/stripe.csv
5 files changed, 184 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/16/397716/1

diff --git a/sites/all/modules/offline2civicrm/StripeFile.php 
b/sites/all/modules/offline2civicrm/StripeFile.php
new file mode 100644
index 000..49b9f03
--- /dev/null
+++ b/sites/all/modules/offline2civicrm/StripeFile.php
@@ -0,0 +1,119 @@
+ 'gateway_txn_id',
+  'utm_source' => 'utm_source',
+  'utm_campaign' => 'utm_campaign',
+  'utm_medium' => 'utm_medium',
+  'Card Address Line1' => 'street_address',
+  'Card Address Line2' => 'supplemental_address_1',
+  'Card Address City' => 'city',
+  'Converted Amount' => 'gross',
+  'Amount' => 'original_gross',
+  'Created (UTC)' => 'date',
+  'Customer Email' => 'email',
+  'Converted Currency' => 'currency',
+  'Currency' => 'original_currency',
+  'Card Name' => 'full_name',
+  'Card Address State' => 'state_province',
+  'Card Address Zip' => 'postal_code',
+  'Card Address Country' => 'country',
+
+
+  //id,
+  //Description,
+  //Amount ,,
+  //Amount Refunded,
+  //Currency,
+  //Converted Amount Refunded,Fee,
+  //Tax,
+  //Converted Currency,
+  //Mode,
+  //Status,
+  //Statement Descriptor,
+  //Customer ID,
+  //Customer Description,,
+  //Captured,Card ID,
+  //Card Last4,
+  //Card Brand,
+  //Card Funding,
+  //Card Exp Month,
+  //Card Exp Year,
+  //Card Issue Country,
+  //Card Fingerprint,
+  //Card CVC Status,
+  //Card AVS Zip Status,
+  //Card AVS Line1 Status,
+  //Card Tokenization Method,
+  //Disputed Amount,
+  //Dispute Status,
+  //Dispute Reason,
+  //Dispute Date (UTC),
+  //Dispute Evidence Due (UTC)
+  //Invoice ID,
+  //Payment Source Type,
+  //Destination,
+  //Transfer,
+  //Transfer Group,
+  //event_id (metadata),
+  //event_name (metadata),
+  //order_number (metadata)
+);
+  }
+
+  protected function getDefaultValues() {
+return array_merge(parent::getDefaultValues(), array(
+'gateway' => 'stripe',
+'no_thank_you' => 'stripe',
+'payment_instrument' => 'Stripe',
+'payment_method' => 'Stripe',
+'utm_medium' => 'MGEventEmail',
+'contact_source' => 'Stripe import',
+  )
+);
+  }
+
+  /**
+   * Read a row and transform into normalized queue message form
+   *
+   * @param $data
+   *
+   * @return array queue message format
+   *
+   * @throws \EmptyRowException
+   * @throws \WmfException
+   */
+  protected function parseRow($data) {
+if (!empty($data['Converted Amount Refunded'])) {
+  throw new WmfException(WmfException::INVALID_MESSAGE, 'Refunds not 
currently handled. Please log a Phab if required');
+}
+return parent::parseRow($data);
+  }
+
+}
diff --git a/sites/all/modules/offline2civicrm/offline2civicrm.info 
b/sites/all/modules/offline2civicrm/offline2civicrm.info
index 4a49a4f..967c081 100644
--- a/sites/all/modules/offline2civicrm/offline2civicrm.info
+++ b/sites/all/modules/offline2civicrm/offline2civicrm.info
@@ -22,6 +22,7 @@
 files[] = PayPalChecksFile.php
 files[] = RefundFile.php
 files[] = SquareFile.php
+files[] = StripeFile.php
 files[] = TrilogyFile.php
 files[] = WmfImportFile.php
 files[] = WmfOrgImportFile.php
diff --git a/sites/all/modules/offline2civicrm/offline2civicrm.module 
b/sites/all/modules/offline2civicrm/offline2civicrm.module
index 71cb137..ed491c3 100644
--- a/sites/all/modules/offline2civicrm/offline2civicrm.module
+++ b/sites/all/modules/offline2civicrm/offline2civicrm.module
@@ -115,6 +115,7 @@
   'jpmorgan' => t('JP Morgan'),
   'paypal' => t('PayPal EFT'),
   'square' => t('Square'),
+  'stripe' => t('Stripe'),
   'trilogy' => t('Trilogy'),
 ),
   );
@@ -194,6 +195,11 @@
 case 'square':
   $importer = new SquareFile($file->uri);
   break;
+
+ca