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
58f661cd
Commit
58f661cd
authored
5 years ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Set the decimal places for the fee amount before saving
parent
0a6b63fc
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!109
6.4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Core/Payment/Stripe.php
+6
-4
6 additions, 4 deletions
CRM/Core/Payment/Stripe.php
with
6 additions
and
4 deletions
CRM/Core/Payment/Stripe.php
+
6
−
4
View file @
58f661cd
...
...
@@ -10,6 +10,7 @@
*/
use
CRM_Stripe_ExtensionUtil
as
E
;
use
Civi\Payment\PropertyBag
;
/**
* Class CRM_Core_Payment_Stripe
...
...
@@ -165,7 +166,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
*
* Handle any inconsistency about how it is passed in here.
*
* @param array $params
* @param array
|PropertyBag
$params
*
* @return string
*/
...
...
@@ -432,7 +433,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
* https://stripe.com/docs/api?lang=php
* Payment processors should set payment_status_id.
*
* @param array $params
* @param array
|PropertyBag
$params
* Assoc array of input parameters for this transaction.
* @param string $component
*
...
...
@@ -725,12 +726,13 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
if
((
$stripeCharge
[
'currency'
]
!==
$stripeBalanceTransaction
[
'currency'
])
&&
(
!
empty
(
$stripeBalanceTransaction
[
'exchange_rate'
])))
{
$newParams
[
'fee_amount'
]
=
(
$stripeBalanceTransaction
->
fee
/
$stripeBalanceTransaction
[
'exchange_rate'
])
/
100
;
$newParams
[
'net_amount'
]
=
(
$stripeBalanceTransaction
->
net
/
$stripeBalanceTransaction
[
'exchange_rate'
])
/
100
;
}
else
{
$newParams
[
'fee_amount'
]
=
$stripeBalanceTransaction
->
fee
/
100
;
$newParams
[
'net_amount'
]
=
$stripeBalanceTransaction
->
net
/
100
;
}
// We must round to currency precision otherwise payments may fail because Contribute BAO saves but then
// can't retrieve because it tries to use the full unrounded number when it only got saved with 2dp.
$newParams
[
'fee_amount'
]
=
round
(
$newParams
[
'fee_amount'
],
CRM_Utils_Money
::
getCurrencyPrecision
(
$stripeCharge
[
'currency'
]));
// Success!
// Set the desired contribution status which will be set later (do not set on the contribution here!)
$params
[
'contribution_status_id'
]
=
CRM_Core_PseudoConstant
::
getKey
(
'CRM_Contribute_BAO_Contribution'
,
'contribution_status_id'
,
'Completed'
);
...
...
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