Extract Stripe utilites

This commit is contained in:
Benjamin Beganović 2020-06-01 14:17:29 +02:00
parent b94ce97bac
commit cf503b4531
2 changed files with 18 additions and 10 deletions

View File

@ -0,0 +1,16 @@
<?php
namespace App\PaymentDrivers\Stripe;
trait Utilities
{
public function convertFromStripeAmount($amount, $precision)
{
return $amount / pow(10, $precision);
}
public function convertToStripeAmount($amount, $precision)
{
return $amount * pow(10, $precision);
}
}

View File

@ -21,6 +21,7 @@ use App\Models\Invoice;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Stripe\Utilities;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
@ -30,7 +31,7 @@ use Stripe\Stripe;
class StripePaymentDriver extends BasePaymentDriver class StripePaymentDriver extends BasePaymentDriver
{ {
use MakesHash; use MakesHash, Utilities;
protected $refundable = true; protected $refundable = true;
@ -374,15 +375,6 @@ class StripePaymentDriver extends BasePaymentDriver
return $payment; return $payment;
} }
public function convertFromStripeAmount($amount, $precision)
{
return $amount / pow(10, $precision);
}
public function convertToStripeAmount($amount, $precision)
{
return $amount * pow(10, $precision);
}
/** /**
* Creates a new String Payment Intent * Creates a new String Payment Intent
* *