diff --git a/app/Http/Controllers/DesignController.php b/app/Http/Controllers/DesignController.php index c6f44abf250a..f2b440056b7d 100644 --- a/app/Http/Controllers/DesignController.php +++ b/app/Http/Controllers/DesignController.php @@ -496,6 +496,7 @@ class DesignController extends BaseController $company = auth()->user()->getCompany(); $design = Design::where('company_id', $company->id) + ->orWhereNull('company_id') ->where('id', $design_id) ->exists(); diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 6084b5164b5a..ecb74e416af5 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -403,10 +403,8 @@ class BaseDriver extends AbstractPaymentDriver }); - } - SystemLogger::dispatch( $gateway->payment_hash, SystemLog::CATEGORY_GATEWAY_RESPONSE, @@ -620,21 +618,27 @@ class BaseDriver extends AbstractPaymentDriver { $types = []; - // if($type == GatewayType::BANK_TRANSFER && $this->company_gateway->fees_and_limits->{GatewayType::BANK_TRANSFER}->is_enabled) - // { - // $types[] = $type; - // } - // elseif($type == GatewayType::CREDIT_CARD && $this->company_gateway->fees_and_limits->{GatewayType::CREDIT_CARD}->is_enabled) - // { - // $types[] = $type; - // } - $types[] = GatewayType::CREDIT_CARD; $types[] = GatewayType::BANK_TRANSFER; return $types; } + /** + * Generic description handler + */ + public function getDescription(bool $abbreviated = true) + { + if(!$this->payment_hash) + return ""; + + if($abbreviated) + return \implode(', ', collect($this->payment_hash->invoices())->pluck('invoice_number')->toArray()); + + return sprintf('%s: %s', ctrans('texts.invoices'), \implode(', ', collect($this->payment_hash->invoices())->pluck('invoice_number')->toArray())); + + } + public function disconnect() { return true; diff --git a/app/PaymentDrivers/CheckoutCom/CreditCard.php b/app/PaymentDrivers/CheckoutCom/CreditCard.php index cb7e728bc742..0cdc3c643b88 100644 --- a/app/PaymentDrivers/CheckoutCom/CreditCard.php +++ b/app/PaymentDrivers/CheckoutCom/CreditCard.php @@ -88,7 +88,6 @@ class CreditCard 'raw_value' => $request->raw_value, 'currency' => $request->currency, 'payment_hash' => $request->payment_hash, - 'reference' => $request->payment_hash, 'client_id' => $this->checkout->client->id, ]; @@ -134,9 +133,10 @@ class CreditCard private function completePayment($method, PaymentResponseRequest $request) { + $payment = new Payment($method, $this->checkout->payment_hash->data->currency); $payment->amount = $this->checkout->payment_hash->data->value; - $payment->reference = $this->checkout->payment_hash->data->reference; + $payment->reference = $this->checkout->getDescription(); $this->checkout->payment_hash->data = array_merge((array)$this->checkout->payment_hash->data, ['checkout_payment_ref' => $payment]); $this->checkout->payment_hash->save(); diff --git a/app/PaymentDrivers/CheckoutComPaymentDriver.php b/app/PaymentDrivers/CheckoutComPaymentDriver.php index e820808316e3..7b4f2aea4a6f 100644 --- a/app/PaymentDrivers/CheckoutComPaymentDriver.php +++ b/app/PaymentDrivers/CheckoutComPaymentDriver.php @@ -243,27 +243,18 @@ class CheckoutComPaymentDriver extends BaseDriver $amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total; $invoice = Invoice::whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')))->withTrashed()->first(); - if ($invoice) { - $description = "Invoice {$invoice->number} for {$amount} for client {$this->client->present()->name()}"; - } else { - $description = "Payment with no invoice for amount {$amount} for client {$this->client->present()->name()}"; - } - $this->init(); $method = new IdSource($cgt->token); $payment = new \Checkout\Models\Payments\Payment($method, $this->client->getCurrencyCode()); $payment->amount = $this->convertToCheckoutAmount($amount, $this->client->getCurrencyCode()); - //$payment->reference = $cgt->meta->last4 . '-' . now(); $payment->reference = $invoice->number . '-' . now(); $request = new PaymentResponseRequest(); $request->setMethod('POST'); $request->request->add(['payment_hash' => $payment_hash->hash]); - //$this->setPaymentHash($payment_hash); - try { $response = $this->gateway->payments()->request($payment);