Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Block/Checkout/LayoutProcessorPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ private function generateKlarnaIframe($quote)
} catch (\Throwable $e) {
if ($e->getCode() === Service::HTTP_UNAUTHORIZED) {
return __(
'Invalid Klarna API Credentials. Please check your Merchant ID, ' .
'Invalid Kustom API Credentials. Please check your Merchant ID, ' .
'Shared Secret, and selected API Version.'
);
}
$errorMessage = $e->getMessage();
$this->manager->addErrorMessage($errorMessage);
return __(
'Klarna Checkout has failed to load. Please ' .
'Kustom Checkout has failed to load. Please ' .
'<a href="javascript:;" onclick="location.reload(true)">reload checkout.</a>'
);
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Api/AddressUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private function getSuccessfulResult(array $response): Json
private function getKlarnaOrderId(): string
{
$klarnaOrderId = $this->request->getParam('id', '');
$this->logger->info('AddressUpdate: Klarna checkout id: ' . $klarnaOrderId);
$this->logger->info('AddressUpdate: Kustom checkout id: ' . $klarnaOrderId);

return $klarnaOrderId;
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/Api/ShippingMethodUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function execute()
$this->logger->info('ShippingMethodUpdate: start');

$klarnaOrderId = $this->request->getParam('id');
$this->logger->info('ShippingMethodUpdate: klarna order id: ' . $klarnaOrderId);
$this->logger->info('ShippingMethodUpdate: Kustom order id: ' . $klarnaOrderId);

try {
$this->klarnaRequestQuoteTransformer->updateQuoteShippingMethod(
Expand Down
2 changes: 1 addition & 1 deletion Controller/Api/UpdateKssStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function execute()

$data = [];
if ($isKssEnabled || $this->session->hasActiveKlarnaShippingGatewayInformation()) {
$this->logger->info('UpdateKssStatus: Updating the values in the Klarna table and quote');
$this->logger->info('UpdateKssStatus: Updating the values in the Kustom table and quote');

$oldGrandTotal = $this->session->getQuote()->getGrandTotal();

Expand Down
4 changes: 2 additions & 2 deletions Controller/Api/Validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function execute()
$this->logger->info('Validate: start');

$checkoutId = $this->request->getParam('id');
$this->logger->info('Validate: Klarna checkout id: ' . $checkoutId);
$this->logger->info('Validate: Kustom checkout id: ' . $checkoutId);

try {
$this->workflowProvider->setKlarnaOrderId($checkoutId);
Expand Down Expand Up @@ -166,7 +166,7 @@ private function getSuccessResponse(): Json
private function setValidateFailedResponse($checkoutId, KlarnaException $e): Redirect
{
$message = $e->getMessage();
$this->logger->warning('Validate: Magento quote does not match Klarna order: ' . $message);
$this->logger->warning('Validate: Magento quote does not match Kustom order: ' . $message);
$this->messageManager->addErrorMessage($message);

return $this->redirectFactory->create()
Expand Down
2 changes: 1 addition & 1 deletion Controller/Klarna/Confirmation.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function __construct(
public function execute()
{
$klarnaOrderId = $this->request->getParam('id');
$this->logger->debug('Klarna order id: ' . $klarnaOrderId);
$this->logger->debug('Kustom order id: ' . $klarnaOrderId);

if (!$klarnaOrderId) {
return $this->getInvalidOrderIdResponse();
Expand Down
11 changes: 9 additions & 2 deletions Gateway/Handler/TitleHandler.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
<?php

/**
* Copyright © Klarna Bank AB (publ)
*
* For the full copyright and license information, please view the NOTICE
* and LICENSE files that were distributed with this source code.
*/

declare(strict_types=1);

namespace Klarna\Kco\Gateway\Handler;

use Magento\Payment\Gateway\Config\ValueHandlerInterface;
use Magento\Payment\Model\InfoInterface;

use function str_replace;

/**
* @internal
*/
class TitleHandler implements ValueHandlerInterface
{
public const DEFAULT_TITLE = 'Klarna Checkout';
public const DEFAULT_TITLE = 'Kustom Checkout';

/**
* Retrieve method configured value
Expand Down Expand Up @@ -48,7 +52,10 @@ public function handle(array $subject, $storeId = null)
public function getTitle($payment)
{
if ($payment->hasAdditionalInformation('method_title')) {
return self::DEFAULT_TITLE . " - " . $payment->getAdditionalInformation('method_title');
$methodTitle = (string) $payment->getAdditionalInformation('method_title');
$methodTitle = str_replace('Klarna', 'Kustom', $methodTitle);

return self::DEFAULT_TITLE . " - " . $methodTitle;
}

return self::DEFAULT_TITLE;
Expand Down
6 changes: 3 additions & 3 deletions Model/Api/Kasper.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function createOrder()
public function retrieveOrder(string $currency, $checkoutId = null)
{
if (!$checkoutId) {
$message = __('Unable to initialize Klarna checkout order');
$message = __('Unable to initialize Kustom checkout order');
throw new KlarnaException($message);
}
$api = $this->getCheckoutApi();
Expand Down Expand Up @@ -174,7 +174,7 @@ private function checkOrderStatus($klarnaOrder)
)
);
}
$message = __('Unable to initialize Klarna checkout order');
$message = __('Unable to initialize Kustom checkout order');

$klarnaErrorMessages = $klarnaOrder->getErrorMessages();
if ($klarnaErrorMessages === null) {
Expand All @@ -183,7 +183,7 @@ private function checkOrderStatus($klarnaOrder)

$apiMessages = implode('<br/>', $klarnaErrorMessages);
if (!empty($apiMessages)) {
$message = __('Unable to initialize Klarna checkout order. Klarna api error: %1', $apiMessages);
$message = __('Unable to initialize Kustom checkout order. Kustom api error: %1', $apiMessages);
}

throw new KlarnaException($message);
Expand Down
2 changes: 1 addition & 1 deletion Model/Cart/Validations/OrderItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function validate(DataObject $request, CartInterface $quote): void
}

$errorMessage = sprintf(
'Order items do not match for quote ID %s. Klarna order items are %s vs Magento order items %s',
'Order items do not match for quote ID %s. Kustom order items are %s vs Magento order items %s',
$quote->getId(),
json_encode($localOrderLines),
json_encode($request->getOrderLines())
Expand Down
2 changes: 1 addition & 1 deletion Model/Cart/Validations/OrderTotal.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function validate(DataObject $request, CartInterface $quote): void

if ($klarnaTotal !== $quoteTotal) {
$exceptionMessage = __(
'Order total does not match for order #%1. Klarna total is %2 vs Magento total %3',
'Order total does not match for order #%1. Kustom total is %2 vs Magento total %3',
$quote->getReservedOrderId(),
$klarnaTotal,
$quoteTotal
Expand Down
2 changes: 1 addition & 1 deletion Model/Cart/Validations/ShippingAmount.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function validate(DataObject $request, CartInterface $quote): void
$klarnaShippingAmount = $this->getShippingAmount($request, $quote);
if ($quoteShippingAmount !== $klarnaShippingAmount) {
$exceptionMessage = __(
'Shipping amount does not match for order %1. Klarna amount is %2 vs Magento amount is %3',
'Shipping amount does not match for order %1. Kustom amount is %2 vs Magento amount is %3',
$quote->getReservedOrderId(),
$klarnaShippingAmount,
$quoteShippingAmount
Expand Down
2 changes: 1 addition & 1 deletion Model/Cart/Validations/ShippingMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function validate(DataObject $request, CartInterface $quote): void
$klarnaShippingMethod = $this->getSelectedKlarnaShippingMethod($request);
if ($quoteShippingMethod !== $klarnaShippingMethod) {
$exceptionMessage = __(
'Shipping method does not match for order #%1. Klarna method is %2 vs Magento method is %3',
'Shipping method does not match for order #%1. Kustom method is %2 vs Magento method is %3',
$quote->getReservedOrderId(),
$klarnaShippingMethod,
$quoteShippingMethod
Expand Down
26 changes: 13 additions & 13 deletions Model/Order/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function createMagentoOrder(string $klarnaOrderId): MagentoOrderInterface
$this->klarnaOrder = $this->workflowProvider->getKlarnaOrder();
$this->klarnaOrder->setReservationId($reservationId);
$this->orderRepository->save($this->klarnaOrder);
$this->logger->debug('Saved the klarna order');
$this->logger->debug('Saved the Kustom order');

return $this->mageOrder;
}
Expand Down Expand Up @@ -295,7 +295,7 @@ public function setOrderStatus(MagentoOrderInterface $order, string $status = ''
}

if (SalesOrder::STATE_PROCESSING === $order->getState()) {
$order->addStatusHistoryComment(__('Order processed by Klarna.'), $status);
$order->addStatusHistoryComment(__('Order processed by Kustom.'), $status);
}
}

Expand Down Expand Up @@ -332,7 +332,7 @@ public function cancelKlarnaOrder(string $klarnaOrderId, string $cancelReason):
}
if ($order->getStatus() !== 'CANCELLED') {
$orderManagement->cancel($klarnaId);
$this->logger->info('Canceled order with Klarna - ' . $cancelReason);
$this->logger->info('Canceled order with Kustom - ' . $cancelReason);
}

if ($magentoOrder !== null && !$magentoOrder->isCanceled()) {
Expand Down Expand Up @@ -369,7 +369,7 @@ public function updateOrderState(string $klarnaOrderId): void
// TODO: Consider saving cancel status in database klarna table
if ($klarnaStatus === KcoApiInterface::ORDER_STATUS_CANCELLED) {
$this->logger->info(
'Klarna order is ' . $klarnaStatus . '. Cancelling Magento order: '
'Kustom order is ' . $klarnaStatus . '. Cancelling Magento order: '
. $this->mageOrder->getIncrementId()
);
$this->cancelMagentoOrder($this->mageOrder, $klarnaStatus);
Expand All @@ -396,7 +396,7 @@ public function updateOrderState(string $klarnaOrderId): void
private function cancelOrder(MagentoOrderInterface $order, string $klarnaOrderId): void
{
if ($order->isCanceled()) {
$this->logger->debug('Cancel the order on the klarna side because it is canceled in the shop');
$this->logger->debug('Cancel the order on the Kustom side because it is canceled in the shop');
$this->cancelKlarnaOrder($klarnaOrderId, 'Order Canceled in Magento');
}
}
Expand Down Expand Up @@ -432,12 +432,12 @@ private function cancelMagentoOrder(MagentoOrderInterface $order, string $klarna
$order->setState(SalesOrder::STATE_CANCELED);
$order->setStatus(SalesOrder::STATE_CANCELED);
$order->addStatusHistoryComment(
__('Order automatically cancelled because Klarna status is: %1', $klarnaStatus)
__('Order automatically cancelled because Kustom status is: %1', $klarnaStatus)
);
$this->mageOrderRepository->save($order);

$this->logger->info(
'Magento order ' . $order->getIncrementId() . ' cancelled due to Klarna status: ' . $klarnaStatus
'Magento order ' . $order->getIncrementId() . ' cancelled due to Kustom status: ' . $klarnaStatus
);
}

Expand Down Expand Up @@ -469,7 +469,7 @@ private function updateOrderWithKlarnaReference(
}
}

$this->logger->debug('Updated the order with the klarna reference');
$this->logger->debug('Updated the order with the Kustom reference');
}

/**
Expand Down Expand Up @@ -503,7 +503,7 @@ private function acknowledgeOrder(
// TODO: Consider: Should we cancel order in Magento here?
throw new KlarnaException(__('Acknowledge call failed. Check log for details.'));
}
$order->addStatusHistoryComment('Acknowledged request sent to Klarna');
$order->addStatusHistoryComment('Acknowledged request sent to Kustom');
$klarnaOrder->setIsAcknowledged(1);
$this->orderRepository->save($klarnaOrder);
}
Expand Down Expand Up @@ -544,15 +544,15 @@ public function checkAndUpdateOrderState(string $orderId): void

$orderDetails = $this->paymentStatus->getStatusUpdate($klarnaOrder);
if (!$orderDetails->getIsSuccessful()) {
throw new LocalizedException(__('An error happened when retrieving the status of the order from Klarna'));
throw new LocalizedException(__('An error happened when retrieving the status of the order from Kustom'));
}

$this->checkOrderState($mageOrder, $orderDetails->getStatus());
if ($this->updateKlarnaOrder($orderDetails->getFraudStatus(), $klarnaOrder)) {
return;
}

throw new LocalizedException(__('Order is still PENDING with Klarna'));
throw new LocalizedException(__('Order is still PENDING with Kustom'));
}

/**
Expand All @@ -570,7 +570,7 @@ private function getKlarnaOrderByMagentoOrder(MagentoOrderInterface $mageOrder):
$this->denyPayment(
$mageOrder,
__(
'Canceled the order since no Klarna information could ' .
'Canceled the order since no Kustom information could ' .
'be found in the Magento database for the order.'
)
);
Expand Down Expand Up @@ -614,7 +614,7 @@ private function checkOrderState(MagentoOrderInterface $mageOrder, string $statu
if (in_array($status, $stopStatuses)) {
$this->denyPayment(
$mageOrder,
__('Canceled the order as Klarna shows it as %1', $status)
__('Canceled the order as Kustom shows it as %1', $status)
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions Model/WorkflowProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function __construct(
public function setKlarnaOrderId(string $klarnaOrderId): void
{
if (empty($klarnaOrderId)) {
throw new KlarnaException(__('The provided Klarna order id is empty'));
throw new KlarnaException(__('The provided Kustom order id is empty'));
}

$this->klarnaOrderId = $klarnaOrderId;
Expand All @@ -112,7 +112,7 @@ public function getKcoQuote(): QuoteInterface
$this->kcoQuote = $this->kcoQuoteRepository->getByCheckoutId($this->klarnaOrderId);
} catch (NoSuchEntityException $e) {
throw new KlarnaException(__(
'No Klarna Kco quote could be found with the provided Klarna order id: %1',
'No Kustom Kco quote could be found with the provided Kustom order id: %1',
$this->klarnaOrderId
));
}
Expand Down Expand Up @@ -156,7 +156,7 @@ public function getKlarnaOrder(): OrderInterface
$this->klarnaOrder = $this->klarnaOrderRepository->getByKlarnaOrderId($this->klarnaOrderId);
} catch (NoSuchEntityException $e) {
throw new KlarnaException(__(
'No Klarna order entry could be found with the provided Klarna order id: %1',
'No Kustom order entry could be found with the provided Kustom order id: %1',
$this->klarnaOrderId
));
}
Expand All @@ -178,7 +178,7 @@ public function getMagentoOrder(): MagentoOrder
$this->magentoOrder = $this->magentoOrderRepository->get($this->getKlarnaOrder()->getOrderId());
} catch (NoSuchEntityException|InputException $e) {
throw new KlarnaException(__(
'No Magento order could be found with the provided Klarna order id: %1',
'No Magento order could be found with the provided Kustom order id: %1',
$this->klarnaOrderId
));
}
Expand Down
2 changes: 1 addition & 1 deletion Plugin/AddPaymentStatusButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function beforeSetLayout(View $view, LayoutInterface $layout)
}

$message = __(
'This will make an API call to Klarna to attempt to update the order state. ' .
'This will make an API call to Kustom to attempt to update the order state. ' .
'Are you sure you want to do this?'
);

Expand Down
Loading