* @throws Exception
*/
public static function create($params) {
+ // If we are creating a new PaymentProcessor and have not specified the payment instrument to use, get the default from the Payment Processor Type.
+ if (empty($params['id']) && empty($params['payment_instrument_id'])) {
+ $params['payment_instrument_id'] = civicrm_api3('PaymentProcessorType', 'getvalue', [
+ 'id' => $params['payment_processor_type_id'],
+ 'return' => 'payment_instrument_id',
+ ]);
+ }
$processor = new CRM_Financial_DAO_PaymentProcessor();
$processor->copyValues($params);
* API result 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', [
- 'id' => $params['payment_processor_type_id'],
- 'return' => 'payment_instrument_id',
- ]);
- }
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'PaymentProcessor');
}
'class_name' => 'CRM_Core_Payment_APITest',
'billing_mode' => 'form',
'is_recur' => 0,
+ 'payment_instrument_id' => 2,
];
$result = $this->callAPISuccess('payment_processor_type', 'create', $params);
$this->_paymentProcessorType = $result['id'];
'frequency_interval' => 1,
]);
$this->getAndCheck($params, $result['id'], 'PaymentProcessor');
+ $this->assertEquals(2, $result['values'][$result['id']]['payment_instrument_id']);
}
/**
*/
public function testPaymentProcessorUpdate() {
$params = $this->_params;
+ $params['payment_instrument_id'] = 1;
$result = $this->callAPISuccess('payment_processor', 'create', $params);
$this->assertNotNull($result['id']);