Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stripe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Extensions
Stripe
Commits
c620713b
Commit
c620713b
authored
2 years ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Add Stripe Authorize Event for API endpoints
parent
c024f811
No related branches found
No related tags found
1 merge request
!209
6.8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Civi/Api4/Action/StripePaymentintent/ProcessMOTO.php
+6
-0
6 additions, 0 deletions
Civi/Api4/Action/StripePaymentintent/ProcessMOTO.php
Civi/Api4/Action/StripePaymentintent/ProcessPublic.php
+11
-5
11 additions, 5 deletions
Civi/Api4/Action/StripePaymentintent/ProcessPublic.php
with
17 additions
and
5 deletions
Civi/Api4/Action/StripePaymentintent/ProcessMOTO.php
+
6
−
0
View file @
c620713b
...
...
@@ -91,6 +91,12 @@ class ProcessMOTO extends \Civi\Api4\Generic\AbstractAction {
* @throws \Stripe\Exception\ApiErrorException
*/
public
function
_run
(
\Civi\Api4\Generic\Result
$result
)
{
$authorizeEvent
=
new
\Civi\Stripe\Event\AuthorizeEvent
(
$this
->
getEntityName
(),
$this
->
getActionName
(),
$this
->
getParams
());
$event
=
\Civi
::
dispatcher
()
->
dispatch
(
'civi.stripe.authorize'
,
$authorizeEvent
);
if
(
$event
->
isAuthorized
()
===
FALSE
)
{
throw
new
\CRM_Core_Exception
(
'Bad Request'
);
}
if
(
empty
(
$this
->
amount
)
&&
!
$this
->
setup
)
{
\Civi
::
log
(
'stripe'
)
->
error
(
__CLASS__
.
'missing amount and not capture or setup'
);
throw
new
\API_Exception
(
'Bad request'
);
...
...
This diff is collapsed.
Click to expand it.
Civi/Api4/Action/StripePaymentintent/ProcessPublic.php
+
11
−
5
View file @
c620713b
...
...
@@ -85,6 +85,13 @@ class ProcessPublic extends \Civi\Api4\Generic\AbstractAction {
*/
protected
$csrfToken
=
''
;
/**
* A captcha token for verification (if enabled)
*
* @var string
*/
protected
$captcha
=
''
;
/**
* @param \Civi\Api4\Generic\Result $result
*
...
...
@@ -93,11 +100,10 @@ class ProcessPublic extends \Civi\Api4\Generic\AbstractAction {
* @throws \Stripe\Exception\ApiErrorException
*/
public
function
_run
(
\Civi\Api4\Generic\Result
$result
)
{
if
(
class_exists
(
'\Civi\Firewall\Firewall'
))
{
$firewall
=
new
\Civi\Firewall\Firewall
();
if
(
!
$firewall
->
checkIsCSRFTokenValid
(
\CRM_Utils_Type
::
validate
(
$this
->
csrfToken
,
'String'
)))
{
throw
new
\CRM_Core_Exception
(
$firewall
->
getReasonDescription
());
}
$authorizeEvent
=
new
\Civi\Stripe\Event\AuthorizeEvent
(
$this
->
getEntityName
(),
$this
->
getActionName
(),
$this
->
getParams
());
$event
=
\Civi
::
dispatcher
()
->
dispatch
(
'civi.stripe.authorize'
,
$authorizeEvent
);
if
(
$event
->
isAuthorized
()
===
FALSE
)
{
throw
new
\CRM_Core_Exception
(
'Bad Request'
);
}
if
(
empty
(
$this
->
amount
)
&&
!
$this
->
setup
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment