Skip to content
Snippets Groups Projects
Commit 189e6408 authored by eileen's avatar eileen
Browse files

Revert "financial#77 ++ Make contribution_id mandatory for PaymentProcessor.pay, pass incoieID"

This reverts commit 783b62a7.
parent 3fe06aa5
Branches
Tags
No related merge requests found
......@@ -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,
];
......
......@@ -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());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment