-
-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getMoney() change from public to private breaks 3rd party gateway integration #186
Comments
This was done to avoid gateways relying on Money, in the cases of breaking changes when Money v3 is not supported anymore. It is possible to use it as input though, but for gateways it's suggested to use to final amount or amountInteger. |
Have you got an example of how to set a tax amount using From what I can tell, both those methods use the amount parameter and there's no way to specify an alternate parameter to use. For our gateway, I have to send an amount parameter and a tax amount parameter and I want the same rules that apply for amount to apply to the tax amount. |
Can you post what you are doing now? Which gateway? |
It's an internal gateway for our institution that uses SOAP. I've created a
As you can probably tell, both these methods are the same as the In the short term, I've copied the |
So what is the tax value when calling setTax? A money object? The setAmount is explicitly just for setting a formatted string, so in that case the input and output would be the same. |
If it's a string already, you can use this function: /**
* Format an amount for the payment currency.
*
* @param string $amount
* @return string
*/
public function formatCurrency($amount)
{
$money = $this->getMoney((string) $amount);
$formatter = new DecimalMoneyFormatter($this->getCurrencies());
return $formatter->format($money);
} For which we could perhaps allow a Money object to be passed into instead of casting to string? |
It's not the fact that its a string or not. I wanted the same rules and checks to apply for tax values as for amounts without having to duplicate methods. The decimal count, whether a negative is allowed, whether a zero amount is allowed. |
Calling formatCurrency will call getMoney and also apply the same validation rules. |
Perfect. Thanks. |
Why was
getMoney
insrc/Common/Message/AbstractRequest.php
changed from public to private?In our 3rd party SOAP gateway, we have to send a tax amount along with the amount. To avoid re-inventing the wheel, I used the
getMoney
method to make sure the tax amount supplied was positive, non-zero etc using all the same rules as for amounts.The text was updated successfully, but these errors were encountered: