-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement PaymentProcessor and PaymentProcessorType APIv4 Entities
Move default values to spec as per Coleman Fix class name in tests and fix default values on tables Mock financial_account_id field
- Loading branch information
1 parent
66d736a
commit ea5e4e9
Showing
15 changed files
with
434 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
{* file to handle db changes in 5.20.alpha1 during upgrade *} | ||
|
||
UPDATE civicrm_navigation SET url = "civicrm/api3" WHERE url = "civicrm/api" AND domain_id = {$domainID}; | ||
|
||
UPDATE civicrm_payment_processor SET is_default = 0 WHERE is_default IS NULL; | ||
UPDATE civicrm_payment_processor SET is_active = 1 WHERE is_active IS NULL; | ||
UPDATE civicrm_payment_processor SET is_test = 0 WHERE is_test IS NULL; | ||
UPDATE civicrm_payment_processor_type SET is_active = 1 WHERE is_active IS NULL; | ||
UPDATE civicrm_payment_processor_type SET is_default = 0 WHERE is_default IS NULL; | ||
ALTER TABLE civicrm_payment_processor ALTER COLUMN is_default SET DEFAULT 0; | ||
ALTER TABLE civicrm_payment_processor ALTER COLUMN is_active SET DEFAULT 1; | ||
ALTER TABLE civicrm_payment_processor ALTER COLUMN is_test SET DEFAULT 0; | ||
ALTER TABLE civicrm_payment_processor_type ALTER COLUMN is_active SET DEFAULT 1; | ||
ALTER TABLE civicrm_payment_processor_type ALTER COLUMN is_default SET DEFAULT 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
Civi/Api4/Action/PaymentProcessor/PaymentProcessorSaveTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?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['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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?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; | ||
|
||
/** | ||
* Relationship entity. | ||
* | ||
* @package Civi\Api4 | ||
*/ | ||
class PaymentProcessor extends Generic\DAOEntity { | ||
|
||
/** | ||
* @return \Civi\Api4\Action\PaymentProcessor\Create | ||
*/ | ||
public static function create() { | ||
return new \Civi\Api4\Action\PaymentProcessor\Create(__CLASS__, __FUNCTION__); | ||
} | ||
|
||
/** | ||
* @return \Civi\Api4\Action\PaymentProcessor\Save | ||
*/ | ||
public static function save() { | ||
return new \Civi\Api4\Action\PaymentProcessor\Save(__CLASS__, __FUNCTION__); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?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; | ||
|
||
/** | ||
* Relationship entity. | ||
* | ||
* @package Civi\Api4 | ||
*/ | ||
class PaymentProcessorType extends Generic\DAOEntity { | ||
|
||
} |
Oops, something went wrong.