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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
wmortada
mjwshared
Commits
fc549598
Commit
fc549598
authored
5 years ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Release 0.4
parent
1cf64d74
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Core/Payment/MJWTrait.php
+73
-0
73 additions, 0 deletions
CRM/Core/Payment/MJWTrait.php
docs/release/release_notes.md
+6
-0
6 additions, 0 deletions
docs/release/release_notes.md
info.xml
+2
-2
2 additions, 2 deletions
info.xml
with
81 additions
and
2 deletions
CRM/Core/Payment/MJWTrait.php
+
73
−
0
View file @
fc549598
...
...
@@ -178,6 +178,8 @@ trait CRM_Core_Payment_MJWTrait {
public
function
getDefaultCurrencyForForm
(
$form
)
{
// For contribution pages it is in $form->_values
$currency
=
CRM_Utils_Array
::
value
(
'currency'
,
$form
->
_values
);
// If we AJAX load and have more than one processor (eg. stripe, pay later) we can end up with the wrong
// currency set in $form->_values. So we use $form->getVar('currency') to get the right one!
if
(
!
$currency
&&
is_a
(
$form
,
'CRM_Financial_Form_Payment'
))
{
$currency
=
$form
->
getVar
(
'currency'
);
}
...
...
@@ -489,4 +491,75 @@ trait CRM_Core_Payment_MJWTrait {
return
$params
;
}
/**
* Get a "token" parameter that was inserted via javascript on the payment form (eg. paymentIntentID).
*
* @param string $parameterName
* @param array $params
*
* @return array
* @throws \CRM_Core_Exception
*/
protected
function
getTokenParameter
(
$parameterName
,
$params
)
{
// Get the passed in parameter
if
(
!
empty
(
CRM_Utils_Array
::
value
(
$parameterName
,
$params
)))
{
$parameterValue
=
CRM_Utils_Array
::
value
(
$parameterName
,
$params
);
}
elseif
(
CRM_Core_Session
::
singleton
()
->
get
(
$parameterName
))
{
// @fixme Hack for contributionpages - see https://github.com/civicrm/civicrm-core/pull/15252
$parameterValue
=
CRM_Core_Session
::
singleton
()
->
get
(
$parameterName
);
CRM_Core_Session
::
singleton
()
->
set
(
$parameterName
,
NULL
);
}
elseif
(
CRM_Utils_Request
::
retrieve
(
$parameterName
,
'String'
))
{
$parameterValue
=
CRM_Utils_Request
::
retrieve
(
$parameterName
,
'String'
);
}
if
(
empty
(
$parameterValue
))
{
Civi
::
log
()
->
debug
(
"
{
$parameterName
}
paymentIntentID not found.
\$
params: "
.
print_r
(
$params
,
TRUE
));
CRM_Core_Error
::
statusBounce
(
E
::
ts
(
'Unable to complete payment! Missing %1.'
,
[
1
=>
$parameterName
]));
}
$params
[
$parameterName
]
=
$parameterValue
;
return
$params
;
}
/**
* Given a submitted form, retrieve a parameter that was added via (an input element added by) javascript.
* Save the parameter in the params array for the form so it's accessible at the end of a multi-page form.
*
* @param string $parameterName
* @param \CRM_Core_Form $form
*
* @throws \CRM_Core_Exception
*/
public
static
function
setTokenParameter
(
$parameterName
,
&
$form
)
{
// Retrieve the paymentIntentID that was posted along with the form and add it to the form params
// This allows multi-page checkout to work (eg. register->confirm->thankyou)
$params
=
$form
->
get
(
'params'
);
if
(
!
$params
)
{
// @fixme Hack for contributionpages - see https://github.com/civicrm/civicrm-core/pull/15252
$params
=
$form
->
getVar
(
'_params'
);
$hackForContributionPages
=
TRUE
;
}
if
(
isset
(
$params
[
'amount'
]))
{
// Contribution pages have params directly in the main array
$paymentParams
=
&
$params
;
}
elseif
(
isset
(
$params
[
0
][
'amount'
]))
{
// Event registration pages have params in a sub-array
$paymentParams
=
&
$params
[
0
];
}
else
{
return
;
}
$paymentIntentID
=
CRM_Utils_Request
::
retrieveValue
(
$parameterName
,
'String'
);
if
(
$paymentIntentID
)
{
$paymentParams
[
$parameterName
]
=
$paymentIntentID
;
$form
->
set
(
'params'
,
$params
);
if
(
isset
(
$hackForContributionPages
))
{
// @fixme Hack for contributionpages - see https://github.com/civicrm/civicrm-core/pull/15252
CRM_Core_Session
::
singleton
()
->
set
(
$parameterName
,
$paymentIntentID
);
}
}
}
}
This diff is collapsed.
Click to expand it.
docs/release/release_notes.md
+
6
−
0
View file @
fc549598
## Release 0.4
*
Fix issue with non-default currency on form when you can choose from more than one payment processor on the form.
*
Add
`getTokenParameter()`
/
`setTokenParameter()`
functions to MJWTrait which should be used when setting parameters
via javascript (eg. Stripe
`paymentIntentID`
) which are required when the payment is actually processed (via
`doPayment()`
).
## Release 0.3
*
Major refactor of MJWIPNTrait.
...
...
This diff is collapsed.
Click to expand it.
info.xml
+
2
−
2
View file @
fc549598
...
...
@@ -13,8 +13,8 @@
<url
desc=
"Support"
>
https://www.mjwconsult.co.uk
</url>
<url
desc=
"Licensing"
>
http://www.gnu.org/licenses/agpl-3.0.html
</url>
</urls>
<releaseDate>
2019-09-1
3
</releaseDate>
<version>
0.
3
</version>
<releaseDate>
2019-09-1
6
</releaseDate>
<version>
0.
4
</version>
<develStage>
stable
</develStage>
<compatibility>
<ver>
5.13
</ver>
...
...
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