Skip to content

Commit

Permalink
Implement PaymentProcessor and PaymentProcessorType APIv4 Entities
Browse files Browse the repository at this point in the history
  • Loading branch information
seamuslee001 committed Oct 27, 2019
1 parent cb4793e commit 3c3333d
Show file tree
Hide file tree
Showing 15 changed files with 453 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CRM/Case/DAO/Case.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Case/Case.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:c5896e4b577b32d8a2c62d3cba65119d)
* (GenCodeChecksum:4fa22b57b48574c5e6643b13964140d4)
*/

/**
Expand Down
6 changes: 5 additions & 1 deletion CRM/Financial/DAO/PaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Financial/PaymentProcessor.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:6d3b0b9b13fae223bc45c6c1e4ce7b94)
* (GenCodeChecksum:1f57ba8617085cdc968ce42aeaca15ec)
*/

/**
Expand Down Expand Up @@ -280,6 +280,7 @@ public static function &fields() {
'name' => 'payment_processor_type_id',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Payment Processor Type ID'),
'required' => TRUE,
'where' => 'civicrm_payment_processor.payment_processor_type_id',
'table_name' => 'civicrm_payment_processor',
'entity' => 'PaymentProcessor',
Expand All @@ -298,6 +299,7 @@ public static function &fields() {
'title' => ts('Processor is Active?'),
'description' => ts('Is this processor active?'),
'where' => 'civicrm_payment_processor.is_active',
'default' => '1',
'table_name' => 'civicrm_payment_processor',
'entity' => 'PaymentProcessor',
'bao' => 'CRM_Financial_BAO_PaymentProcessor',
Expand All @@ -309,6 +311,7 @@ public static function &fields() {
'title' => ts('Processor Is Default?'),
'description' => ts('Is this processor the default?'),
'where' => 'civicrm_payment_processor.is_default',
'default' => '0',
'table_name' => 'civicrm_payment_processor',
'entity' => 'PaymentProcessor',
'bao' => 'CRM_Financial_BAO_PaymentProcessor',
Expand All @@ -320,6 +323,7 @@ public static function &fields() {
'title' => ts('Is Test Processor?'),
'description' => ts('Is this processor for a test site?'),
'where' => 'civicrm_payment_processor.is_test',
'default' => '0',
'table_name' => 'civicrm_payment_processor',
'entity' => 'PaymentProcessor',
'bao' => 'CRM_Financial_BAO_PaymentProcessor',
Expand Down
7 changes: 6 additions & 1 deletion CRM/Financial/DAO/PaymentProcessorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Financial/PaymentProcessorType.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:65231e0b77bcce22bd505b89ace63506)
* (GenCodeChecksum:c48a828ea82a92860f9f6dc5817c3230)
*/

/**
Expand Down Expand Up @@ -196,6 +196,7 @@ public static function &fields() {
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Payment Processor variable name to be used in code'),
'description' => ts('Payment Processor Name.'),
'required' => TRUE,
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
'where' => 'civicrm_payment_processor_type.name',
Expand All @@ -209,6 +210,7 @@ public static function &fields() {
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Payment Processor Title'),
'description' => ts('Payment Processor Name.'),
'required' => TRUE,
'maxlength' => 127,
'size' => CRM_Utils_Type::HUGE,
'where' => 'civicrm_payment_processor_type.title',
Expand Down Expand Up @@ -236,6 +238,7 @@ public static function &fields() {
'title' => ts('Processor Type Is Active?'),
'description' => ts('Is this processor active?'),
'where' => 'civicrm_payment_processor_type.is_active',
'default' => '1',
'table_name' => 'civicrm_payment_processor_type',
'entity' => 'PaymentProcessorType',
'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
Expand All @@ -247,6 +250,7 @@ public static function &fields() {
'title' => ts('Processor Type is Default?'),
'description' => ts('Is this processor the default?'),
'where' => 'civicrm_payment_processor_type.is_default',
'default' => '0',
'table_name' => 'civicrm_payment_processor_type',
'entity' => 'PaymentProcessorType',
'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
Expand Down Expand Up @@ -304,6 +308,7 @@ public static function &fields() {
'name' => 'class_name',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Suffix for PHP class name implementation'),
'required' => TRUE,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
'where' => 'civicrm_payment_processor_type.class_name',
Expand Down
43 changes: 43 additions & 0 deletions Civi/Api4/Action/PaymentProcessor/Create.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/*
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2019
* $Id$
*
*/


namespace Civi\Api4\Action\PaymentProcessor;

class Create extends \Civi\Api4\Generic\DAOCreateAction {
use PaymentProcessorSaveTrait;

}
65 changes: 65 additions & 0 deletions Civi/Api4/Action/PaymentProcessor/PaymentProcessorSaveTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

/*
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2019
* $Id$
*
*/

namespace Civi\Api4\Action\PaymentProcessor;

/**
* @inheritDoc
*/
trait PaymentProcessorSaveTrait {

/**
* @inheritDoc
*/
protected function writeObjects($items) {
foreach ($items as &$item) {
if (empty($item['domain_id'])) {
$item['domain_id'] = \CRM_Core_Config::domainID();
}
if (empty($item['financial_account_id'])) {
$item['financial_account_id'] = \CRM_Financial_BAO_PaymentProcessor::getDefaultFinancialAccountID();
}
if (empty($item['payment_instrument_id'])) {
$paymentProcessorTypes = \Civi\Api4\PaymentProcessorType::get()->addWhere('id', '=', $item['payment_processor_type_id'])->execute();
foreach ($paymentProcessorTypes as $paymentProcessorType) {
$item['payment_instrument_id'] = $paymentProcessorType['payment_instrument_id'];
}
}
}
return parent::writeObjects($items);
}

}
43 changes: 43 additions & 0 deletions Civi/Api4/Action/PaymentProcessor/Save.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/*
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2019
* $Id$
*
*/


namespace Civi\Api4\Action\PaymentProcessor;

class Save extends \Civi\Api4\Generic\DAOSaveAction {
use PaymentProcessorSaveTrait;

}
43 changes: 43 additions & 0 deletions Civi/Api4/Action/PaymentProcessorType/Create.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/*
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2019
* $Id$
*
*/


namespace Civi\Api4\Action\PaymentProcessorType;

class Create extends \Civi\Api4\Generic\DAOCreateAction {
use PaymentProcessorTypeSaveTrait;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/*
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2019
* $Id$
*
*/


namespace Civi\Api4\Action\PaymentProcessorType;

/**
* @inheritDoc
*/
trait PaymentProcessorTypeSaveTrait {

/**
* @inheritDoc
*/
protected function writeObjects($items) {
foreach ($items as &$item) {
if (empty($item['payment_instrument_id'])) {
$item['payment_instrument_id'] = 'Credit Card';
}
}
return parent::writeObjects($items);
}

}
43 changes: 43 additions & 0 deletions Civi/Api4/Action/PaymentProcessorType/Save.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/*
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2019
* $Id$
*
*/


namespace Civi\Api4\Action\PaymentProcessorType;

class Save extends \Civi\Api4\Generic\DAOSaveAction {
use PaymentProcessorTypeSaveTrait;

}
Loading

0 comments on commit 3c3333d

Please sign in to comment.