mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Fix support for currencies with varying precisions
This commit is contained in:
parent
1ce3a023cd
commit
b98a569888
@ -209,18 +209,21 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
// Need to use Stripe's new Payment Intent API.
|
||||
$this->prepareStripeAPI();
|
||||
|
||||
// Get information about the currency we're using.
|
||||
$currency = Cache::get('currencies')->where('code', strtoupper($data['currency']))->first();
|
||||
|
||||
if ( ! empty($data['payment_intent'])) {
|
||||
// Find the existing payment intent.
|
||||
$intent = PaymentIntent::retrieve($data['payment_intent']);
|
||||
|
||||
if ( ! $intent->amount == $data['amount'] * 100) {
|
||||
if ( ! $intent->amount == $data['amount'] * pow(10, $currency['precision'])) {
|
||||
// Make sure that the provided payment intent matches the invoice amount.
|
||||
throw new Exception('Incorrect PaymentIntent amount.');
|
||||
}
|
||||
$intent->confirm();
|
||||
} elseif ( ! empty($data['token']) || ! empty($data['payment_method'])) {
|
||||
$params = [
|
||||
'amount' => $data['amount'] * 100,
|
||||
'amount' => $data['amount'] * pow(10, $currency['precision']),
|
||||
'currency' => $data['currency'],
|
||||
'confirmation_method' => 'manual',
|
||||
'confirm' => true,
|
||||
|
Loading…
Reference in New Issue
Block a user