Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mjwshared
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
mjwshared
Commits
1129c8ce
Commit
1129c8ce
authored
2 years ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Convert some internals to API4
parent
b33ca019
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!40
Support for Stripe 6.9 release
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Core/Payment/MJWIPNTrait.php
+16
-13
16 additions, 13 deletions
CRM/Core/Payment/MJWIPNTrait.php
CRM/Core/Payment/MJWTrait.php
+17
-8
17 additions, 8 deletions
CRM/Core/Payment/MJWTrait.php
api/v3/Mjwpayment.php
+14
-11
14 additions, 11 deletions
api/v3/Mjwpayment.php
with
47 additions
and
32 deletions
CRM/Core/Payment/MJWIPNTrait.php
+
16
−
13
View file @
1129c8ce
...
...
@@ -9,6 +9,7 @@
+--------------------------------------------------------------------+
*/
use
Civi\Api4\Contribution
;
use
Civi\Payment\Exception\PaymentProcessorException
;
/**
...
...
@@ -125,7 +126,7 @@ trait CRM_Core_Payment_MJWIPNTrait {
// Non-recurring contribution.
else
{
try
{
$this
->
is_email_receipt
=
\Civi\Api4\
Contribution
::
get
(
FALSE
)
$this
->
is_email_receipt
=
Contribution
::
get
(
FALSE
)
->
addSelect
(
'contribution_page_id.is_email_receipt'
)
->
addWhere
(
'id'
,
'='
,
$contributionID
)
->
execute
()
...
...
@@ -293,9 +294,11 @@ trait CRM_Core_Payment_MJWIPNTrait {
*/
private
function
updateRecurCompleted
(
$params
)
{
$this
->
checkRequiredParams
(
'updateRecurCompleted'
,
[
'id'
],
$params
);
$params
[
'contribution_status_id'
]
=
'Completed'
;
civicrm_api3
(
'ContributionRecur'
,
'create'
,
$params
);
\Civi\Api4\ContributionRecur
::
update
(
FALSE
)
->
addWhere
(
'id'
,
'='
,
$params
[
'id'
])
->
addValue
(
'contribution_status_id:name'
,
'Completed'
)
->
execute
();
}
/**
...
...
@@ -326,11 +329,11 @@ trait CRM_Core_Payment_MJWIPNTrait {
*
* @param array $params
*
* @return
bool
* @return
int
* @throws \CiviCRM_API3_Exception
* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
private
function
repeatContribution
(
$params
)
{
private
function
repeatContribution
(
array
$params
)
:
int
{
$this
->
checkRequiredParams
(
'repeatContribution'
,
[
...
...
@@ -399,7 +402,7 @@ trait CRM_Core_Payment_MJWIPNTrait {
$paymentParams
[
'skipCleanMoney'
]
=
TRUE
;
civicrm_api3
(
'Mjwpayment'
,
'create_payment'
,
$paymentParams
);
}
return
TRUE
;
return
$contribution
[
'id'
]
;
}
/**
...
...
@@ -475,13 +478,13 @@ trait CRM_Core_Payment_MJWIPNTrait {
*/
private
function
updateContributionFailed
(
$params
)
{
$this
->
checkRequiredParams
(
'updateContributionFailed'
,
[
'contribution_id'
,
'order_reference'
],
$params
);
civicrm_api3
(
'Contribution'
,
'create'
,
[
'contribution_status_id
'
=>
'Failed'
,
'id'
=>
$params
[
'contribution_id
'
]
,
'trxn_id'
=>
$params
[
'order_reference'
],
'cancel_date'
=>
$params
[
'cancel_
date
'
]
??
NULL
,
'cancel_reason'
=>
$params
[
'cancel_reason'
]
??
NULL
,
]
);
Contribution
::
update
(
FALSE
)
->
addValue
(
'contribution_status_id
:name'
,
'Failed'
)
->
addValue
(
'trxn_id'
,
$params
[
'order_reference
'
]
)
->
addValue
(
'cancel_date'
,
$params
[
'cancel_date'
]
??
''
)
->
addValue
(
'cancel_reason'
,
$params
[
'cancel_
reason
'
]
??
''
)
->
addWhere
(
'id'
,
'='
,
$params
[
'contribution_id'
])
->
execute
(
);
// No financial_trxn is created so we don't need to update that.
}
...
...
This diff is collapsed.
Click to expand it.
CRM/Core/Payment/MJWTrait.php
+
17
−
8
View file @
1129c8ce
...
...
@@ -47,21 +47,30 @@ trait CRM_Core_Payment_MJWTrait {
/**
* Get the billing email address
*
* @param array $params
* @param int $contactI
d
* @param
\Civi\Payment\PropertyBag|
array $params
* @param int $contactI
D
*
* @return string|NULL
*/
public
function
getBillingEmail
(
$params
,
$contactId
)
{
public
function
getBillingEmail
(
$propertyBag
,
$contactID
=
NULL
)
{
// We want this function to take a single argument - propertyBag but for legacy compatibility
// we still accept an array and the second parameter contactID.
// Start: Hackery to convert this function to take propertyBag
$propertyBag
=
PropertyBag
::
cast
(
$propertyBag
);
if
(
empty
(
$contactID
)
&&
$propertyBag
->
has
(
'contactID'
))
{
$contactID
=
$propertyBag
->
getContactID
();
}
$params
=
$this
->
getPropertyBagAsArray
(
$propertyBag
);
// End: Hackery to convert this function to take propertyBag
$billingLocationId
=
CRM_Core_BAO_LocationType
::
getBilling
();
$emailAddress
=
$params
[
"email-
{
$billingLocationId
}
"
]
??
$params
[
'email-Primary'
]
??
$params
[
'email'
]
??
NULL
;
if
(
empty
(
$emailAddress
)
&&
!
empty
(
$contactI
d
))
{
if
(
empty
(
$emailAddress
)
&&
!
empty
(
$contactI
D
))
{
// Try and retrieve an email address from Contact ID
$emailAddresses
=
civicrm_api3
(
'Email'
,
'get'
,
[
'contact_id'
=>
$contactId
,
'return'
=>
[
'email'
,
'location_type_id'
,
'is_primary'
],
])[
'values'
];
$emailAddresses
=
\Civi\Api4\Email
::
get
(
FALSE
)
->
addWhere
(
'contact_id'
,
'='
,
$contactID
)
->
execute
();
$other_options
=
[];
foreach
(
$emailAddresses
as
$row
)
{
...
...
This diff is collapsed.
Click to expand it.
api/v3/Mjwpayment.php
+
14
−
11
View file @
1129c8ce
...
...
@@ -91,17 +91,18 @@ function civicrm_api3_mjwpayment_get_contribution($params) {
// We may have more than one payment (eg. A payment + a refund payment)
// Return the contribution of the FIRST payment (all found payments SHOULD reference the same contribution)
$contributionID
=
reset
(
$payments
[
'values'
])[
'contribution_id'
];
$contribution
=
civicrm_api3
(
'Contribution'
,
'getsingle'
,
[
'id'
=>
$contributionID
,
'contribution_test'
=>
$params
[
'contribution_test'
],
]);
$contribution
=
\Civi\Api4\Contribution
::
get
(
FALSE
)
->
addWhere
(
'id'
,
'='
,
$contributionID
)
->
addWhere
(
'is_test'
,
'IN'
,
[
TRUE
,
FALSE
])
->
execute
()
->
first
();
$contribution
[
'payments'
]
=
$payments
[
'values'
];
}
else
{
$contribution
Params
=
[
'options'
=>
[
'limit'
=>
1
,
'sort'
=>
'id DESC'
],
'contribution_test'
=>
$params
[
'contribution_test'
],
];
$contribution
Api4
=
\Civi\Api4\Contribution
::
get
(
FALSE
)
->
addWhere
(
'is_test'
,
'IN'
,
[
TRUE
,
FALSE
])
->
addOrderBy
(
'id'
,
'DESC'
);
if
(
isset
(
$params
[
'order_reference'
]))
{
$contributionParams
[
'trxn_id'
][]
=
$params
[
'order_reference'
];
}
...
...
@@ -109,10 +110,12 @@ function civicrm_api3_mjwpayment_get_contribution($params) {
$contributionParams
[
'trxn_id'
][]
=
$params
[
'trxn_id'
];
}
if
(
isset
(
$contributionParams
[
'trxn_id'
]))
{
$contributionParams
[
'trxn_id'
]
=
[
'IN'
=>
$contributionParams
[
'trxn_id'
]];
$contributionApi4
->
addWhere
(
'trxn_id'
,
'IN'
,
$contributionParams
[
'trxn_id'
]);
}
if
(
isset
(
$params
[
'contribution_id'
]))
{
$contributionApi4
->
addWhere
(
'id'
,
'='
,
$params
[
'contribution_id'
]);
}
$contribution
=
civicrm_api3
(
'Contribution'
,
'get'
,
$contributionParams
)[
'values'
];
$contribution
=
reset
(
$contribution
);
$contribution
=
$contributionApi4
->
execute
()
->
first
();
}
$result
=
[];
if
(
$contribution
)
{
...
...
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