From 189e6408db997688e3dfa83db4c4db2e363c62e1 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 2 Nov 2019 19:06:12 +1300 Subject: [PATCH] Revert "dev/financial#77 ++ Make contribution_id mandatory for PaymentProcessor.pay, pass incoieID" This reverts commit 783b62a7dfe3c94bd69bcb182732b240e53911be. --- api/v3/PaymentProcessor.php | 6 +-- tests/phpunit/api/v3/PaymentProcessorTest.php | 42 ------------------- 2 files changed, 2 insertions(+), 46 deletions(-) diff --git a/api/v3/PaymentProcessor.php b/api/v3/PaymentProcessor.php index a414717970..e2406dc5d0 100644 --- a/api/v3/PaymentProcessor.php +++ b/api/v3/PaymentProcessor.php @@ -124,10 +124,8 @@ function _civicrm_api3_payment_processor_getlist_defaults(&$request) { * API result array. * * @throws \API_Exception - * @throws \CiviCRM_API3_Exception */ function civicrm_api3_payment_processor_pay($params) { - /* @var CRM_Core_Payment $processor */ $processor = Civi\Payment\System::singleton()->getById($params['payment_processor_id']); $processor->setPaymentProcessor(civicrm_api3('PaymentProcessor', 'getsingle', ['id' => $params['payment_processor_id']])); try { @@ -141,7 +139,7 @@ function civicrm_api3_payment_processor_pay($params) { } throw new API_Exception('Payment failed', $code, $errorData, $e); } - return civicrm_api3_create_success([$result], $params); + return civicrm_api3_create_success(array($result), $params); } /** @@ -151,7 +149,7 @@ function civicrm_api3_payment_processor_pay($params) { */ function _civicrm_api3_payment_processor_pay_spec(&$params) { $params['payment_processor_id'] = [ - 'api.required' => TRUE, + 'api.required' => 1, 'title' => ts('Payment processor'), 'type' => CRM_Utils_Type::T_INT, ]; diff --git a/tests/phpunit/api/v3/PaymentProcessorTest.php b/tests/phpunit/api/v3/PaymentProcessorTest.php index 6c54af7867..60ccd4e5ce 100644 --- a/tests/phpunit/api/v3/PaymentProcessorTest.php +++ b/tests/phpunit/api/v3/PaymentProcessorTest.php @@ -35,11 +35,6 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase { protected $_apiversion = 3; protected $_params; - /** - * Set up for class. - * - * @throws \CRM_Core_Exception - */ public function setUp() { parent::setUp(); $this->useTransaction(TRUE); @@ -74,8 +69,6 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase { /** * Create payment processor. - * - * @throws \Exception */ public function testPaymentProcessorCreate() { $params = $this->_params; @@ -95,8 +88,6 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase { /** * Update payment processor. - * - * @throws \CRM_Core_Exception */ public function testPaymentProcessorUpdate() { $params = $this->_params; @@ -140,8 +131,6 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase { /** * Check payment processor delete. - * - * @throws \CRM_Core_Exception */ public function testPaymentProcessorDelete() { $result = $this->callAPISuccess('payment_processor', 'create', $this->_params); @@ -154,8 +143,6 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase { /** * Check with valid params array. - * - * @throws \CRM_Core_Exception */ public function testPaymentProcessorsGet() { $params = $this->_params; @@ -171,33 +158,4 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase { $this->assertEquals('test@test.com', $results['values'][$results['id']]['user_name']); } - /** - * Test the processor passed to the hook can access the relevant variables. - * - * @throws \CRM_Core_Exception - * @throws \CiviCRM_API3_Exception - */ - public function testPaymentProcessorPay() { - $this->hookClass->setHook('civicrm_alterPaymentProcessorParams', [$this, 'hook_civicrm_alterPaymentProcessorParams']); - $processor = $this->dummyProcessorCreate(); - $this->callAPISuccess('PaymentProcessor', 'pay', [ - 'payment_processor_id' => $processor->getID(), - 'contribution_id' => 10, - 'invoice_id' => 2, - 'contribution_recur_id' => 3, - 'amount' => 6, - ]); - } - - /** - * Implements civicrm_alterPaymentProcessorParams hook. - * - * @param \CRM_Core_Payment_Dummy $paymentObject - */ - public function hook_civicrm_alterPaymentProcessorParams($paymentObject) { - $this->assertEquals(10, $paymentObject->getContributionID()); - $this->assertEquals(2, $paymentObject->getInvoiceID()); - $this->assertEquals(3, $paymentObject->getContributionRecurID()); - } - } -- 2.25.1