Skip to content
Snippets Groups Projects
Commit faada2bb authored by mattwire's avatar mattwire
Browse files

If Stripe is not using the same currency as the payment was made we need to...

If Stripe is not using the same currency as the payment was made we need to convert the fees/net amounts back to the CiviCRM currency
parent dd41651e
Branches
Tags
1 merge request!1096.4
......@@ -697,8 +697,15 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$errorMessage = $this->handleErrorNotification($err, $params['stripe_error_url']);
throw new \Civi\Payment\Exception\PaymentProcessorException('Failed to retrieve Stripe Balance Transaction: ' . $errorMessage);
}
$newParams['fee_amount'] = $stripeBalanceTransaction->fee / 100;
$newParams['net_amount'] = $stripeBalanceTransaction->net / 100;
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;
}
// 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');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment