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
520ed349
Commit
520ed349
authored
7 years ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Simply error handling and improve error reporting of unknown errors
parent
b24bc18b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Core/Payment/Stripe.php
+17
-46
17 additions, 46 deletions
CRM/Core/Payment/Stripe.php
with
17 additions
and
46 deletions
CRM/Core/Payment/Stripe.php
+
17
−
46
View file @
520ed349
...
...
@@ -144,46 +144,6 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
break
;
}
}
catch
(
Stripe_CardError
$e
)
{
$this
->
logStripeException
(
$op
,
$e
);
$error_message
=
''
;
// Since it's a decline, Stripe_CardError will be caught
$body
=
$e
->
getJsonBody
();
$err
=
$body
[
'error'
];
//$error_message .= 'Status is: ' . $e->getHttpStatus() . "<br />";
////$error_message .= 'Param is: ' . $err['param'] . "<br />";
$error_message
.
=
'Type: '
.
$err
[
'type'
]
.
'<br />'
;
$error_message
.
=
'Code: '
.
$err
[
'code'
]
.
'<br />'
;
$error_message
.
=
'Message: '
.
$err
[
'message'
]
.
'<br />'
;
$newnote
=
civicrm_api3
(
'Note'
,
'create'
,
array
(
'sequential'
=>
1
,
'entity_id'
=>
$params
[
'contactID'
],
'contact_id'
=>
$params
[
'contributionID'
],
'subject'
=>
$err
[
'type'
],
'note'
=>
$err
[
'code'
],
'entity_table'
=>
"civicrm_contributions"
,
));
if
(
isset
(
$error_url
))
{
// Redirect to first page of form and present error.
CRM_Core_Error
::
statusBounce
(
"Oops! Looks like there was an error. Payment Response:
<br />
{
$error_message
}
"
,
$error_url
);
}
else
{
// Don't have return url - return error object to api
$core_err
=
CRM_Core_Error
::
singleton
();
$message
=
'Oops! Looks like there was an error. Payment Response: <br />'
.
$error_message
;
if
(
$err
[
'code'
])
{
$core_err
->
push
(
$err
[
'code'
],
0
,
NULL
,
$message
);
}
else
{
$core_err
->
push
(
9000
,
0
,
NULL
,
'Unknown Error'
);
}
return
$core_err
;
}
}
catch
(
Exception
$e
)
{
if
(
is_a
(
$e
,
'Stripe_Error'
))
{
foreach
(
$ignores
as
$ignore
)
{
...
...
@@ -195,9 +155,9 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
}
}
}
$this
->
logStripeException
(
$op
,
$e
);
}
// Something else happened, completely unrelated to Stripe
$this
->
logStripeException
(
$op
,
$e
);
$error_message
=
''
;
// Since it's a decline, Stripe_CardError will be caught
$body
=
$e
->
getJsonBody
();
...
...
@@ -205,9 +165,20 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
//$error_message .= 'Status is: ' . $e->getHttpStatus() . "<br />";
////$error_message .= 'Param is: ' . $err['param'] . "<br />";
$error_message
.
=
'Type: '
.
$err
[
'type'
]
.
"<br />"
;
$error_message
.
=
'Code: '
.
$err
[
'code'
]
.
"<br />"
;
$error_message
.
=
'Message: '
.
$err
[
'message'
]
.
"<br />"
;
$error_message
.
=
'Type: '
.
$err
[
'type'
]
.
'<br />'
;
$error_message
.
=
'Code: '
.
$err
[
'code'
]
.
'<br />'
;
$error_message
.
=
'Message: '
.
$err
[
'message'
]
.
'<br />'
;
if
(
is_a
(
$e
,
'Stripe_CardError'
))
{
$newnote
=
civicrm_api3
(
'Note'
,
'create'
,
array
(
'sequential'
=>
1
,
'entity_id'
=>
$params
[
'contactID'
],
'contact_id'
=>
$params
[
'contributionID'
],
'subject'
=>
$err
[
'type'
],
'note'
=>
$err
[
'code'
],
'entity_table'
=>
"civicrm_contributions"
,
));
}
if
(
isset
(
$error_url
))
{
// Redirect to first page of form and present error.
...
...
@@ -222,7 +193,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$core_err
->
push
(
$err
[
'code'
],
0
,
NULL
,
$message
);
}
else
{
$core_err
->
push
(
9000
,
0
,
NULL
,
'Unknown Error
'
);
$core_err
->
push
(
9000
,
0
,
NULL
,
'Unknown Error
: '
.
$message
);
}
return
$core_err
;
}
...
...
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