Skip to content
Snippets Groups Projects
Commit afeeaf73 authored by mattwire's avatar mattwire
Browse files

Require that paymentprocessor is passed into intent processor

parent a1d9f685
No related branches found
No related tags found
No related merge requests found
......@@ -41,18 +41,7 @@ class CRM_Stripe_PaymentIntent {
/**
* @param \CRM_Core_Payment_Stripe $paymentProcessor
*/
public function __construct($paymentProcessor = NULL) {
if ($paymentProcessor) {
$this->setPaymentProcessor($paymentProcessor);
}
}
/**
* @param \CRM_Core_Payment_Stripe $paymentProcessor
*
* @return void
*/
public function setPaymentProcessor(\CRM_Core_Payment_Stripe $paymentProcessor) {
public function __construct(\CRM_Core_Payment_Stripe $paymentProcessor) {
$this->paymentProcessor = $paymentProcessor;
}
......@@ -354,9 +343,6 @@ class CRM_Stripe_PaymentIntent {
// This parameter has security implications and great care should be taken when setting it to TRUE.
$params['moto'] = $params['moto'] ?? FALSE;
/** @var \CRM_Core_Payment_Stripe $paymentProcessor */
$paymentProcessor = \Civi\Payment\System::singleton()->getById($params['paymentProcessorID']);
$this->setPaymentProcessor($paymentProcessor);
if ($this->paymentProcessor->getPaymentProcessor()['class_name'] !== 'Payment_Stripe') {
\Civi::log('stripe')->error(__CLASS__ . " payment processor {$params['paymentProcessorID']} is not Stripe");
return (object) ['ok' => FALSE, 'message' => 'Payment processor is not Stripe', 'data' => []];
......
......@@ -105,8 +105,9 @@ class ProcessMOTO extends \Civi\Api4\Generic\AbstractAction {
\Civi::log('stripe')->error(__CLASS__ . ' missing paymentProcessorID');
throw new \API_Exception('Bad request');
}
$intentProcessor = new \CRM_Stripe_PaymentIntent();
/** @var \CRM_Core_Payment_Stripe $paymentProcessor */
$paymentProcessor = \Civi\Payment\System::singleton()->getById($this->paymentProcessorID);
$intentProcessor = new \CRM_Stripe_PaymentIntent($paymentProcessor);
$intentProcessor->setDescription($this->description);
$intentProcessor->setReferrer($_SERVER['HTTP_REFERER'] ?? '');
$intentProcessor->setExtraData($this->extraData ?? '');
......
......@@ -127,8 +127,9 @@ class ProcessPublic extends \Civi\Api4\Generic\AbstractAction {
\Civi::log('stripe')->error(__CLASS__ . ' missing paymentProcessorID');
throw new \CRM_Core_Exception('Bad request');
}
$intentProcessor = new \CRM_Stripe_PaymentIntent();
/** @var \CRM_Core_Payment_Stripe $paymentProcessor */
$paymentProcessor = \Civi\Payment\System::singleton()->getById($this->paymentProcessorID);
$intentProcessor = new \CRM_Stripe_PaymentIntent($paymentProcessor);
$intentProcessor->setDescription($this->description);
$intentProcessor->setReferrer($_SERVER['HTTP_REFERER'] ?? '');
$intentProcessor->setExtraData($this->extraData ?? '');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment