CRM-16914 add payment_instrument_id field to payment processor type, payment processor
authorEileen McNaughton <eileen@fuzion.co.nz>
Wed, 29 Jul 2015 09:23:38 +0000 (21:23 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Wed, 29 Jul 2015 22:25:55 +0000 (10:25 +1200)
CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl
api/v3/PaymentProcessor.php
api/v3/PaymentProcessorType.php
xml/schema/Financial/PaymentProcessor.xml
xml/schema/Financial/PaymentProcessorType.xml

index e9eb3e1fae37c955a0433ff8ca1fd3b98be0374a..238daaf4f27c816e0524a85140dbc8dfe28a7e9b 100644 (file)
@@ -25,3 +25,13 @@ UPDATE civicrm_option_value SET {localize field="label"}label = 'Activity Summar
 {include file='../CRM/Upgrade/4.7.alpha1.msg_template/civicrm_msg_template.tpl'}
 
 UPDATE civicrm_state_province SET name = 'Bataan' WHERE name = 'Batasn';
+
+--CRM-16914
+ALTER TABLE civicrm_payment_processor
+ADD COLUMN
+`payment_instrument_id` int unsigned   DEFAULT 1 COMMENT 'Payment Instrument ID';
+
+ALTER TABLE civicrm_payment_processor_type
+ADD COLUMN
+`payment_instrument_id` int unsigned   DEFAULT 1 COMMENT 'Payment Instrument ID';
+
index 177b882b11aefc2ac37b6025fceafea1bfe95db0..54ff1db80e166b519e8b94f8505b9ac0ffc1a825 100644 (file)
  * @return array
  */
 function civicrm_api3_payment_processor_create($params) {
+  if (empty($params['id']) && empty($params['payment_instrument_id'])) {
+    $params['payment_instrument_id'] = civicrm_api3('PaymentProcessorType', 'getvalue', array(
+      'id' => $params['payment_processor_type_id'],
+      'return' => 'payment_instrument_id',
+    ));
+  }
   return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }
 
index 2836db242b16ffcca8238a432a9eb0dafd4d504d..8ad42cc0ef64220aa7bc1979b9e84fbe4a24ca20 100644 (file)
@@ -69,6 +69,7 @@ function _civicrm_api3_payment_processor_type_create_spec(&$params) {
   // FIXME bool support // $params['is_recur']['api.required'] = 1;
   $params['name']['api.required'] = 1;
   $params['title']['api.required'] = 1;
+  $params['payment_instrument_id']['api.default'] = 'Credit Card';
 }
 
 /**
index 1659af0e6494cc3aaf27a5489cf308036c0896aa..e93e0a77551184b4a4922df7fce91f59015f44a8 100644 (file)
     <title>Processor Billing Mode</title>
     <type>int unsigned</type>
     <required>true</required>
-    <comment>Billing Mode</comment>
+    <comment>Billing Mode (deprecated)</comment>
     <add>1.8</add>
   </field>
   <field>
     <title>Payment Type</title>
     <type>int unsigned</type>
     <default>1</default>
-    <comment>Payment Type: Credit or Debit</comment>
+    <comment>Payment Type: Credit or Debit (deprecated)</comment>
     <add>3.0</add>
   </field>
+  <field>
+    <name>payment_instrument_id</name>
+    <title>Payment Instrument</title>
+    <type>int unsigned</type>
+    <default>1</default>
+    <comment>Payment Instrument ID</comment>
+    <pseudoconstant>
+      <optionGroupName>payment_instrument</optionGroupName>
+    </pseudoconstant>
+    <add>4.7</add>
+  </field>
 </table>
index bb775170a18f404dd2e85d51c19a74f70c1e51d4..e5cd323f10c1f9364e9f592d319db97301622735 100644 (file)
     <name>billing_mode</name>
     <type>int unsigned</type>
     <required>true</required>
-    <comment>Billing Mode</comment>
+    <comment>Billing Mode (deprecated)</comment>
     <pseudoconstant>
       <callback>CRM_Core_SelectValues::billingMode</callback>
     </pseudoconstant>
     <title>Processor Type Payment Type</title>
     <type>int unsigned</type>
     <default>1</default>
-    <comment>Payment Type: Credit or Debit</comment>
+    <comment>Payment Type: Credit or Debit (deprecated)</comment>
     <add>3.0</add>
   </field>
+  <field>
+    <name>payment_instrument_id</name>
+    <title>Payment Instrument</title>
+    <type>int unsigned</type>
+    <default>1</default>
+    <comment>Payment Instrument ID</comment>
+    <pseudoconstant>
+      <optionGroupName>payment_instrument</optionGroupName>
+    </pseudoconstant>
+    <add>4.7</add>
+  </field>
 </table>