From dbade2f497b9c6978204c71f681681427c6237d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 29 Jan 2021 12:00:30 +0100 Subject: [PATCH] wip --- .../CheckoutComPaymentDriver.php | 9 +------- app/Services/Invoice/AutoBillInvoice.php | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/app/PaymentDrivers/CheckoutComPaymentDriver.php b/app/PaymentDrivers/CheckoutComPaymentDriver.php index 09b75625590b..ed38ba8abd8c 100644 --- a/app/PaymentDrivers/CheckoutComPaymentDriver.php +++ b/app/PaymentDrivers/CheckoutComPaymentDriver.php @@ -215,7 +215,7 @@ class CheckoutComPaymentDriver extends BaseDriver $request->setMethod('POST'); $request->request->add(['payment_hash' => $payment_hash->hash]); - $this->setPaymentHash($payment_hash); + //$this->setPaymentHash($payment_hash); try { $response = $this->gateway->payments()->request($payment); @@ -252,13 +252,6 @@ class CheckoutComPaymentDriver extends BaseDriver $amount ); - PaymentFailureMailer::dispatch( - $this->client, - $response, - $this->client->company, - $amount - ); - $message = [ 'server_response' => $response, 'data' => $payment_hash->data, diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 7641f6caad30..be038abb5ec7 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -49,11 +49,11 @@ class AutoBillInvoice extends AbstractService $this->invoice = $this->invoice->service()->markSent()->save(); /* Mark the invoice as paid if there is no balance */ - if ((int)$this->invoice->balance == 0) + if ((int)$this->invoice->balance == 0) return $this->invoice->service()->markPaid()->save(); - + //if the credits cover the payments, we stop here, build the payment with credits and exit early - if ($this->client->getSetting('use_credits_payment') != 'off') + if ($this->client->getSetting('use_credits_payment') != 'off') $this->applyCreditPayment(); /* Determine $amount */ @@ -70,9 +70,9 @@ class AutoBillInvoice extends AbstractService $gateway_token = $this->getGateway($amount); /* Bail out if no payment methods available */ - if (! $gateway_token || ! $gateway_token->gateway->driver($this->client)->token_billing) + if (! $gateway_token || ! $gateway_token->gateway->driver($this->client)->token_billing) return $this->invoice; - + /* $gateway fee */ $fee = $gateway_token->gateway->calcGatewayFee($amount, $gateway_token->gateway_type_id, $this->invoice->uses_inclusive_taxes); @@ -86,6 +86,7 @@ class AutoBillInvoice extends AbstractService $payment = $gateway_token->gateway ->driver($this->client) + ->setPaymentHash($payment_hash) ->tokenBilling($gateway_token, $payment_hash); return $this->invoice; @@ -257,7 +258,7 @@ class AutoBillInvoice extends AbstractService * @param float $amount The amount to charge * @return ClientGatewayToken The client gateway token */ - // private function + // private function // { // $gateway_tokens = $this->client->gateway_tokens()->orderBy('is_default', 'DESC')->get(); @@ -276,18 +277,18 @@ class AutoBillInvoice extends AbstractService $gateway_tokens = $this->client->gateway_tokens; $filtered_gateways = $gateway_tokens->filter(function ($gateway_token) use($amount) { - + $company_gateway = $gateway_token->gateway; //check if fees and limits are set - if (isset($company_gateway->fees_and_limits) && property_exists($company_gateway->fees_and_limits, $gateway_token->gateway_type_id)) + if (isset($company_gateway->fees_and_limits) && property_exists($company_gateway->fees_and_limits, $gateway_token->gateway_type_id)) { //if valid we keep this gateway_token - if ($this->invoice->client->validGatewayForAmount($company_gateway->fees_and_limits->{$gateway_token->gateway_type_id}, $amount)) + if ($this->invoice->client->validGatewayForAmount($company_gateway->fees_and_limits->{$gateway_token->gateway_type_id}, $amount)) return true; else return false; - + } return true; //if no fees_and_limits set then we automatically must add this gateway