php-cs-fixer

This commit is contained in:
Benjamin Beganović 2020-11-27 12:08:42 +01:00
parent 2618a1d3b8
commit 0aff363f5d
10 changed files with 54 additions and 47 deletions

View File

@ -26,9 +26,8 @@ class TempRouteController extends Controller
public function index(string $hash) public function index(string $hash)
{ {
$data = []; $data = [];
$data['html'] = Cache::get($hash); $data['html'] = Cache::get($hash);
return view('pdf.html', $data); return view('pdf.html', $data);
} }
} }

View File

@ -199,9 +199,9 @@ class PreviewController extends BaseController
->design($design) ->design($design)
->build(); ->build();
if (config('ninja.phantomjs_pdf_generation')) { if (config('ninja.phantomjs_pdf_generation')) {
return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true)); return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true));
} }
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company()); $file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());

View File

@ -11,7 +11,6 @@
namespace App\Models; namespace App\Models;
use App\Models\TaxRate;
use Illuminate\Database\Eloquent\Relations\Pivot; use Illuminate\Database\Eloquent\Relations\Pivot;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
@ -58,7 +57,7 @@ class CompanyUser extends Pivot
public function tax_rates() public function tax_rates()
{ {
return $this->hasMany(TaxRate::class,'company_id', 'company_id'); return $this->hasMany(TaxRate::class, 'company_id', 'company_id');
} }
public function account() public function account()

View File

@ -166,7 +166,8 @@ class AuthorizeCreditCard
$payment_record = []; $payment_record = [];
$payment_record['amount'] = $amount; $payment_record['amount'] = $amount;
$payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER;; $payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER;
;
$payment_record['transaction_reference'] = $response->getTransactionResponse()->getTransId(); $payment_record['transaction_reference'] = $response->getTransactionResponse()->getTransId();
$payment = $this->authorize->createPayment($payment_record); $payment = $this->authorize->createPayment($payment_record);

View File

@ -13,11 +13,8 @@
namespace App\PaymentDrivers\Authorize; namespace App\PaymentDrivers\Authorize;
use App\Exceptions\GenericPaymentDriverFailure; use App\Exceptions\GenericPaymentDriverFailure;
use App\Models\ClientGatewayToken;
use App\Models\GatewayType; use App\Models\GatewayType;
use App\PaymentDrivers\AuthorizePaymentDriver; use App\PaymentDrivers\AuthorizePaymentDriver;
use App\PaymentDrivers\Authorize\AuthorizeCreateCustomer;
use App\PaymentDrivers\Authorize\AuthorizeCreditCard;
use net\authorize\api\contract\v1\CreateCustomerPaymentProfileRequest; use net\authorize\api\contract\v1\CreateCustomerPaymentProfileRequest;
use net\authorize\api\contract\v1\CustomerAddressType; use net\authorize\api\contract\v1\CustomerAddressType;
use net\authorize\api\contract\v1\CustomerPaymentProfileType; use net\authorize\api\contract\v1\CustomerPaymentProfileType;
@ -46,19 +43,16 @@ class AuthorizePaymentMethod
public function authorizeView() public function authorizeView()
{ {
if($this->authorize->payment_method instanceof AuthorizeCreditCard){ if ($this->authorize->payment_method instanceof AuthorizeCreditCard) {
$this->payment_method_id = GatewayType::CREDIT_CARD; $this->payment_method_id = GatewayType::CREDIT_CARD;
return $this->authorizeCreditCard(); return $this->authorizeCreditCard();
} }
// case GatewayType::BANK_TRANSFER: // case GatewayType::BANK_TRANSFER:
// return $this->authorizeBankTransfer(); // return $this->authorizeBankTransfer();
// break; // break;
} }
public function authorizeResponseView($request) public function authorizeResponseView($request)
@ -116,7 +110,6 @@ class AuthorizePaymentMethod
public function createClientGatewayToken($payment_profile, $gateway_customer_reference) public function createClientGatewayToken($payment_profile, $gateway_customer_reference)
{ {
$data = []; $data = [];
$additonal = []; $additonal = [];

View File

@ -31,8 +31,8 @@ use App\Utils\Traits\MakesHash;
use App\Utils\Traits\SystemLogTrait; use App\Utils\Traits\SystemLogTrait;
use Checkout\Library\Exceptions\CheckoutHttpException; use Checkout\Library\Exceptions\CheckoutHttpException;
use Exception; use Exception;
use Illuminate\Support\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
/** /**
* Class BaseDriver. * Class BaseDriver.
@ -83,35 +83,43 @@ class BaseDriver extends AbstractPaymentDriver
* Authorize a payment method. * Authorize a payment method.
* *
* Returns a reusable token for storage for future payments * Returns a reusable token for storage for future payments
* *
* @param array $data * @param array $data
* @return mixed Return a view for collecting payment method information * @return mixed Return a view for collecting payment method information
*/ */
public function authorizeView(array $data) {} public function authorizeView(array $data)
{
}
/** /**
* The payment authorization response * The payment authorization response
* *
* @param Request $request * @param Request $request
* @return mixed Return a response for collecting payment method information * @return mixed Return a response for collecting payment method information
*/ */
public function authorizeResponse(Request $request) {} public function authorizeResponse(Request $request)
{
}
/** /**
* Process a payment * Process a payment
* *
* @param array $data * @param array $data
* @return mixed Return a view for the payment * @return mixed Return a view for the payment
*/ */
public function processPaymentView(array $data) {} public function processPaymentView(array $data)
{
}
/** /**
* Process payment response * Process payment response
* *
* @param Request $request * @param Request $request
* @return mixed Return a response for the payment * @return mixed Return a response for the payment
*/ */
public function processPaymentResponse(Request $request) {} public function processPaymentResponse(Request $request)
{
}
/** /**
* Executes a refund attempt for a given amount with a transaction_reference. * Executes a refund attempt for a given amount with a transaction_reference.
@ -121,7 +129,9 @@ class BaseDriver extends AbstractPaymentDriver
* @param bool $return_client_response Whether the method needs to return a response (otherwise we assume an unattended payment) * @param bool $return_client_response Whether the method needs to return a response (otherwise we assume an unattended payment)
* @return mixed * @return mixed
*/ */
public function refund(Payment $payment, $amount, $return_client_response = false) {} public function refund(Payment $payment, $amount, $return_client_response = false)
{
}
/** /**
* Process an unattended payment. * Process an unattended payment.
@ -130,14 +140,18 @@ class BaseDriver extends AbstractPaymentDriver
* @param PaymentHash $payment_hash The Payment hash containing the payment meta data * @param PaymentHash $payment_hash The Payment hash containing the payment meta data
* @return void The payment response * @return void The payment response
*/ */
public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash){} public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
{
}
/** /**
* Set the inbound request payment method type for access. * Set the inbound request payment method type for access.
* *
* @param int $payment_method_id The Payment Method ID * @param int $payment_method_id The Payment Method ID
*/ */
public function setPaymentMethod($payment_method_id){} public function setPaymentMethod($payment_method_id)
{
}
/************************** Helper methods *************************************/ /************************** Helper methods *************************************/
@ -334,9 +348,9 @@ class BaseDriver extends AbstractPaymentDriver
/** /**
* Wrapper method for checking if resource is good. * Wrapper method for checking if resource is good.
* *
* @param mixed $resource * @param mixed $resource
* @return bool * @return bool
*/ */
public function checkRequiredResource($resource): bool public function checkRequiredResource($resource): bool
{ {
@ -436,7 +450,7 @@ class BaseDriver extends AbstractPaymentDriver
if (Str::startsWith($field, 'billing')) { if (Str::startsWith($field, 'billing')) {
unset($this->required_fields[$position]); unset($this->required_fields[$position]);
} }
} }
if ($this->checkRequiredResource(auth()->user('contact')->client->postal_code)) { if ($this->checkRequiredResource(auth()->user('contact')->client->postal_code)) {
$this->required_fields[] = 'postal_code'; $this->required_fields[] = 'postal_code';

View File

@ -55,19 +55,18 @@ class YourGatewayPaymentDriver extends BaseDriver
return $this->payment_method->paymentView($data); //this is your custom implementation from here return $this->payment_method->paymentView($data); //this is your custom implementation from here
} }
public function processPaymentResponse($request) public function processPaymentResponse($request)
{ {
return $this->payment_method->paymentResponse($request); //this is your custom implementation from here return $this->payment_method->paymentResponse($request); //this is your custom implementation from here
} }
public function refund(Payment $payment, $amount, $return_client_response = false) public function refund(Payment $payment, $amount, $return_client_response = false)
{ {
return $this->payment_method->yourRefundImplementationHere(); //this is your custom implementation from here return $this->payment_method->yourRefundImplementationHere(); //this is your custom implementation from here
} }
public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
{ {
return $this->payment_method->yourTokenBillingImplmentation(); //this is your custom implementation from here return $this->payment_method->yourTokenBillingImplmentation(); //this is your custom implementation from here
} }
} }

View File

@ -26,6 +26,7 @@ use App\Utils\Traits\MakesHash;
use Exception; use Exception;
use Omnipay\Common\Item; use Omnipay\Common\Item;
use stdClass; use stdClass;
class PayPalExpressPaymentDriver extends BasePaymentDriver class PayPalExpressPaymentDriver extends BasePaymentDriver
{ {
use MakesHash; use MakesHash;
@ -56,7 +57,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
const SYSTEM_LOG_TYPE = SystemLog::TYPE_PAYPAL; const SYSTEM_LOG_TYPE = SystemLog::TYPE_PAYPAL;
public function checkRequirements() public function checkRequirements()
{ {
if ($this->company_gateway->require_billing_address) { if ($this->company_gateway->require_billing_address) {
if ($this->checkRequiredResource(auth()->user('contact')->client->address1)) { if ($this->checkRequiredResource(auth()->user('contact')->client->address1)) {
@ -145,7 +146,7 @@ public function checkRequirements()
if (Str::startsWith($field, 'billing')) { if (Str::startsWith($field, 'billing')) {
unset($this->required_fields[$position]); unset($this->required_fields[$position]);
} }
} }
if ($this->checkRequiredResource(auth()->user('contact')->client->postal_code)) { if ($this->checkRequiredResource(auth()->user('contact')->client->postal_code)) {
$this->required_fields[] = 'postal_code'; $this->required_fields[] = 'postal_code';
@ -157,9 +158,9 @@ public function checkRequirements()
/** /**
* Wrapper method for checking if resource is good. * Wrapper method for checking if resource is good.
* *
* @param mixed $resource * @param mixed $resource
* @return bool * @return bool
*/ */
public function checkRequiredResource($resource): bool public function checkRequiredResource($resource): bool
{ {

View File

@ -22,10 +22,10 @@ use App\Utils\CurlUtils;
use App\Utils\HtmlEngine; use App\Utils\HtmlEngine;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Cache;
class Phantom class Phantom
{ {
@ -90,7 +90,7 @@ class Phantom
Cache::put($hash, $html, 300); Cache::put($hash, $html, 300);
$url = route('tmp_pdf', ['hash' => $hash]); $url = route('tmp_pdf', ['hash' => $hash]);
info($url); info($url);
$key = config('ninja.phantomjs_key'); $key = config('ninja.phantomjs_key');
$phantom_url = "https://phantomjscloud.com/api/browser/v2/{$key}/?request=%7Burl:%22{$url}%22,renderType:%22pdf%22%7D"; $phantom_url = "https://phantomjscloud.com/api/browser/v2/{$key}/?request=%7Burl:%22{$url}%22,renderType:%22pdf%22%7D";
$pdf = CurlUtils::get($phantom_url); $pdf = CurlUtils::get($phantom_url);

View File

@ -79,14 +79,15 @@ class SystemHealth
'npm_status' => self::checkNpm(), 'npm_status' => self::checkNpm(),
'node_status' => self::checkNode(), 'node_status' => self::checkNode(),
'cache_enabled' => self::checkConfigCache(), 'cache_enabled' => self::checkConfigCache(),
'phantom_enabled' => (bool) config('ninja.phantomjs_pdf_generation'), 'phantom_enabled' => (bool) config('ninja.phantomjs_pdf_generation'),
]; ];
} }
public static function checkConfigCache() public static function checkConfigCache()
{ {
if(env('APP_URL')) if (env('APP_URL')) {
return false; return false;
}
return true; return true;
} }