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
3651685b
Commit
3651685b
authored
4 years ago
by
mattwire
Committed by
mattwire
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Make testIPNContribution() work again
parent
cfabcc72
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!152
6.6 to master
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/v3/Stripe/Listevents.php
+0
-4
0 additions, 4 deletions
api/v3/Stripe/Listevents.php
tests/phpunit/CRM/Stripe/IpnTest.php
+20
-9
20 additions, 9 deletions
tests/phpunit/CRM/Stripe/IpnTest.php
with
20 additions
and
13 deletions
api/v3/Stripe/Listevents.php
+
0
−
4
View file @
3651685b
...
...
@@ -206,10 +206,6 @@ function civicrm_api3_stripe_Listevents($params) {
$processor
->
setAPIParams
();
$data_list
=
\Stripe\Event
::
all
(
$args
);
if
(
array_key_exists
(
'error'
,
$data_list
))
{
$err
=
$data_list
[
'error'
];
throw
new
API_Exception
(
/*errorMessage*/
"Stripe returned an error: "
.
$err
->
message
,
/*errorCode*/
$err
->
type
);
}
$out
=
$data_list
;
if
(
$params
[
'output'
]
==
'brief'
)
{
$out
=
[];
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/CRM/Stripe/IpnTest.php
+
20
−
9
View file @
3651685b
...
...
@@ -48,6 +48,7 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
$payment_extra_params
=
[
'is_recur'
=>
1
,
'contributionRecurID'
=>
$this
->
contributionRecurID
,
'contributionID'
=>
$this
->
contributionID
,
'frequency_unit'
=>
$this
->
frequency_unit
,
'frequency_interval'
=>
$this
->
frequency_interval
,
'installments'
=>
$this
->
installments
,
...
...
@@ -55,7 +56,7 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
$this
->
doPayment
(
$payment_extra_params
);
// Ensure contribution status is set to pending.
$status_id
=
civicrm_api3
(
'Contribution'
,
'getvalue'
,
[
'id'
=>
$this
->
contributionID
,
'return'
=>
'contribution_status_id'
]);
$status_id
=
civicrm_api3
(
'Contribution'
,
'getvalue'
,
[
'id'
=>
$this
->
contributionID
,
'return'
=>
'contribution_status_id'
]);
$this
->
assertEquals
(
2
,
$status_id
);
// Now check to see if an event was triggered and if so, process it.
...
...
@@ -64,7 +65,7 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
$this
->
ipn
(
$payment_object
);
}
// Ensure Contribution status is updated to complete.
$status_id
=
civicrm_api3
(
'Contribution'
,
'getvalue'
,
[
'id'
=>
$this
->
contributionID
,
'return'
=>
'contribution_status_id'
]);
$status_id
=
civicrm_api3
(
'Contribution'
,
'getvalue'
,
[
'id'
=>
$this
->
contributionID
,
'return'
=>
'contribution_status_id'
]);
$this
->
assertEquals
(
1
,
$status_id
);
}
...
...
@@ -90,25 +91,35 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
// Now try to retrieve this transaction.
// Give it a few seconds to be processed...
sleep
(
5
);
$transactions
=
civicrm_api3
(
'Stripe'
,
'listevents'
,
$params
);
$transactions
=
civicrm_api3
(
'Stripe'
,
'listevents'
,
$params
);
foreach
(
$transactions
[
'values'
][
'data'
]
as
$transaction
)
{
if
(
$transaction
->
data
->
object
->
$property
==
$this
->
processorID
)
{
return
$transaction
;
}
}
return
NULL
;
}
/**
* Run the webhook/ipn
*
*/
public
function
ipn
(
$data
,
$verify
=
TRUE
)
{
// The $_GET['processor_id'] value is normally set by
// CRM_Core_Payment::handlePaymentMethod
$_GET
[
'processor_id'
]
=
$this
->
paymentProcessorID
;
$ipnClass
=
new
CRM_Core_Payment_StripeIPN
(
$data
,
$verify
);
public
function
ipn
(
$event
,
$verifyRequest
=
TRUE
)
{
$ipnClass
=
new
CRM_Core_Payment_StripeIPN
();
$ipnClass
->
setEventID
(
$event
->
id
);
if
(
!
$ipnClass
->
setEventType
(
$event
->
type
))
{
// We don't handle this event
return
FALSE
;
};
$ipnClass
->
setVerifyData
(
$verifyRequest
);
if
(
!
$verifyRequest
)
{
$ipnClass
->
setData
(
$event
->
data
);
}
$ipnClass
->
setPaymentProcessor
(
$this
->
paymentProcessorID
);
$ipnClass
->
setExceptionMode
(
FALSE
);
if
(
isset
(
$emailReceipt
))
{
$ipnClass
->
setSendEmailReceipt
(
$emailReceipt
);
}
$ipnClass
->
processWebhook
();
}
...
...
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