Skip to content
Snippets Groups Projects
Commit a577396a authored by JKingsnorth's avatar JKingsnorth Committed by mattwire
Browse files

User feedback on request authorization and validation issues

parent 4286bc81
No related branches found
No related tags found
1 merge request!214User feedback on request authorization and validation issues
Pipeline #1140 skipped
...@@ -165,12 +165,12 @@ function civicrm_api3_stripe_paymentintent_process($params) { ...@@ -165,12 +165,12 @@ function civicrm_api3_stripe_paymentintent_process($params) {
$authorizeEvent = new \Civi\Stripe\Event\AuthorizeEvent('StripePaymentintent', 'process', $params); $authorizeEvent = new \Civi\Stripe\Event\AuthorizeEvent('StripePaymentintent', 'process', $params);
$event = \Civi::dispatcher()->dispatch('civi.stripe.authorize', $authorizeEvent); $event = \Civi::dispatcher()->dispatch('civi.stripe.authorize', $authorizeEvent);
if ($event->isAuthorized() === FALSE) { if ($event->isAuthorized() === FALSE) {
_civicrm_api3_stripe_paymentintent_returnInvalid(E::ts('Bad Request')); return civicrm_api3_create_error(E::ts('There was a problem authorizing or validating your request.'));
} }
foreach ($params as $key => $value) { foreach ($params as $key => $value) {
if (substr($key, 0, 3) === 'api') { if (substr($key, 0, 3) === 'api') {
_civicrm_api3_stripe_paymentintent_returnInvalid('Invalid params'); return civicrm_api3_create_error(E::ts('There was a problem authorizing or validating your request.'));
} }
} }
$paymentMethodID = CRM_Utils_Type::validate($params['payment_method_id'] ?? '', 'String'); $paymentMethodID = CRM_Utils_Type::validate($params['payment_method_id'] ?? '', 'String');
...@@ -182,7 +182,7 @@ function civicrm_api3_stripe_paymentintent_process($params) { ...@@ -182,7 +182,7 @@ function civicrm_api3_stripe_paymentintent_process($params) {
// authentication from the user (eg. on the confirmation page). So we don't need the amount // authentication from the user (eg. on the confirmation page). So we don't need the amount
// in this case. // in this case.
if (empty($amount) && !$capture && !$setup) { if (empty($amount) && !$capture && !$setup) {
_civicrm_api3_stripe_paymentintent_returnInvalid(); return civicrm_api3_create_error(E::ts('There was a problem authorizing or validating your request.'));
} }
$description = CRM_Utils_Type::validate($params['description'], 'String'); $description = CRM_Utils_Type::validate($params['description'], 'String');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment