This commit is contained in:
Benjamin Beganović 2021-01-29 12:00:30 +01:00
parent 8bbfbbb9e1
commit dbade2f497
2 changed files with 12 additions and 18 deletions

View File

@ -215,7 +215,7 @@ class CheckoutComPaymentDriver extends BaseDriver
$request->setMethod('POST'); $request->setMethod('POST');
$request->request->add(['payment_hash' => $payment_hash->hash]); $request->request->add(['payment_hash' => $payment_hash->hash]);
$this->setPaymentHash($payment_hash); //$this->setPaymentHash($payment_hash);
try { try {
$response = $this->gateway->payments()->request($payment); $response = $this->gateway->payments()->request($payment);
@ -252,13 +252,6 @@ class CheckoutComPaymentDriver extends BaseDriver
$amount $amount
); );
PaymentFailureMailer::dispatch(
$this->client,
$response,
$this->client->company,
$amount
);
$message = [ $message = [
'server_response' => $response, 'server_response' => $response,
'data' => $payment_hash->data, 'data' => $payment_hash->data,

View File

@ -49,11 +49,11 @@ class AutoBillInvoice extends AbstractService
$this->invoice = $this->invoice->service()->markSent()->save(); $this->invoice = $this->invoice->service()->markSent()->save();
/* Mark the invoice as paid if there is no balance */ /* 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(); return $this->invoice->service()->markPaid()->save();
//if the credits cover the payments, we stop here, build the payment with credits and exit early //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(); $this->applyCreditPayment();
/* Determine $amount */ /* Determine $amount */
@ -70,9 +70,9 @@ class AutoBillInvoice extends AbstractService
$gateway_token = $this->getGateway($amount); $gateway_token = $this->getGateway($amount);
/* Bail out if no payment methods available */ /* 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; return $this->invoice;
/* $gateway fee */ /* $gateway fee */
$fee = $gateway_token->gateway->calcGatewayFee($amount, $gateway_token->gateway_type_id, $this->invoice->uses_inclusive_taxes); $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 $payment = $gateway_token->gateway
->driver($this->client) ->driver($this->client)
->setPaymentHash($payment_hash)
->tokenBilling($gateway_token, $payment_hash); ->tokenBilling($gateway_token, $payment_hash);
return $this->invoice; return $this->invoice;
@ -257,7 +258,7 @@ class AutoBillInvoice extends AbstractService
* @param float $amount The amount to charge * @param float $amount The amount to charge
* @return ClientGatewayToken The client gateway token * @return ClientGatewayToken The client gateway token
*/ */
// private function // private function
// { // {
// $gateway_tokens = $this->client->gateway_tokens()->orderBy('is_default', 'DESC')->get(); // $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; $gateway_tokens = $this->client->gateway_tokens;
$filtered_gateways = $gateway_tokens->filter(function ($gateway_token) use($amount) { $filtered_gateways = $gateway_tokens->filter(function ($gateway_token) use($amount) {
$company_gateway = $gateway_token->gateway; $company_gateway = $gateway_token->gateway;
//check if fees and limits are set //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 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; return true;
else else
return false; return false;
} }
return true; //if no fees_and_limits set then we automatically must add this gateway return true; //if no fees_and_limits set then we automatically must add this gateway