Skip to content

Commit 5479073

Browse files
committed
Revert "Add klarna_debug"
This reverts commit 6c39dc9
1 parent 9ff162a commit 5479073

File tree

3 files changed

+85
-111
lines changed

3 files changed

+85
-111
lines changed

src/Module/KlarnaCheckout.php

+85-99
Original file line numberDiff line numberDiff line change
@@ -183,23 +183,16 @@ protected function compile()
183183
// Resume, just make sure the cart is up to date
184184
$klarnaCheckout = new KlarnaOrder($connector, $klarnaOrderId);
185185
try {
186-
$data = [
186+
$klarnaCheckout->update(
187+
[
187188
'order_amount' => (int) round($this->cart->getTotal() * 100, 0),
188189
'order_tax_amount' => (int) round(
189190
($this->cart->getTotal() - $this->cart->getTaxFreeTotal()) * 100,
190191
0
191192
),
192193
'order_lines' => $this->orderLines(),
193-
];
194-
195-
if ($this->config->klarna_debug) {
196-
log_message(
197-
sprintf("New Klarna update request:\n\n%s\n", var_export($data, true)),
198-
'klarna_api.log'
199-
);
200-
}
201-
202-
$klarnaCheckout->update($data);
194+
]
195+
);
203196
} catch (RequestException $e) {
204197
$klarnaCheckout = null;
205198
} catch (ConnectorException $e) {
@@ -222,98 +215,91 @@ protected function compile()
222215
}
223216
}
224217

225-
$data = [
226-
'purchase_country' => $this->config->country,
227-
'purchase_currency' => $this->config->currency,
228-
'locale' => $this->request->getLocale(),
229-
'order_amount' => (int) round($this->cart->getTotal() * 100, 0),
230-
'order_tax_amount' => (int) round(
231-
($this->cart->getTotal() - $this->cart->getTaxFreeTotal()) * 100,
218+
$klarnaCheckout = new KlarnaOrder($connector);
219+
$klarnaCheckout->create(
220+
[
221+
'purchase_country' => $this->config->country,
222+
'purchase_currency' => $this->config->currency,
223+
'locale' => $this->request->getLocale(),
224+
'order_amount' => (int) round($this->cart->getTotal() * 100, 0),
225+
'order_tax_amount' => (int) round(
226+
($this->cart->getTotal() - $this->cart->getTaxFreeTotal()) * 100,
232227
0
233-
),
234-
'order_lines' => $this->orderLines(),
235-
'merchant_urls' => [
236-
'terms' => $this->uri($this->klarna_terms_page),
237-
'cancellation_terms' => $this->uri($this->klarna_cancellation_terms_page),
238-
'checkout' => $this->uri($this->klarna_checkout_page),
239-
'confirmation' => $this->uri($this->klarna_confirmation_page)
240-
. '?klarna_order_id={checkout.order.id}',
241-
'push' => urldecode(
242-
System::getContainer()->get('router')->generate(
243-
'richardhj.klarna_checkout.push',
244-
['orderId' => '{checkout.order.id}'],
245-
UrlGeneratorInterface::ABSOLUTE_URL
246-
)
247228
),
248-
'shipping_option_update' => urldecode(
249-
System::getContainer()->get('router')->generate(
250-
'richardhj.klarna_checkout.callback.shipping_option_update',
251-
['orderId' => '{checkout.order.id}'],
252-
UrlGeneratorInterface::ABSOLUTE_URL
253-
)
254-
),
255-
'address_update' => urldecode(
256-
System::getContainer()->get('router')->generate(
257-
'richardhj.klarna_checkout.callback.address_update',
258-
['orderId' => '{checkout.order.id}'],
259-
UrlGeneratorInterface::ABSOLUTE_URL
260-
)
261-
),
262-
'country_change' => urldecode(
263-
System::getContainer()->get('router')->generate(
264-
'richardhj.klarna_checkout.callback.country_change',
265-
['orderId' => '{checkout.order.id}'],
229+
'order_lines' => $this->orderLines(),
230+
'merchant_urls' => [
231+
'terms' => $this->uri($this->klarna_terms_page),
232+
'cancellation_terms' => $this->uri($this->klarna_cancellation_terms_page),
233+
'checkout' => $this->uri($this->klarna_checkout_page),
234+
'confirmation' => $this->uri($this->klarna_confirmation_page)
235+
. '?klarna_order_id={checkout.order.id}',
236+
'push' => urldecode(
237+
System::getContainer()->get('router')->generate(
238+
'richardhj.klarna_checkout.push',
239+
['orderId' => '{checkout.order.id}'],
240+
UrlGeneratorInterface::ABSOLUTE_URL
241+
)
242+
),
243+
'shipping_option_update' => urldecode(
244+
System::getContainer()->get('router')->generate(
245+
'richardhj.klarna_checkout.callback.shipping_option_update',
246+
['orderId' => '{checkout.order.id}'],
247+
UrlGeneratorInterface::ABSOLUTE_URL
248+
)
249+
),
250+
'address_update' => urldecode(
251+
System::getContainer()->get('router')->generate(
252+
'richardhj.klarna_checkout.callback.address_update',
253+
['orderId' => '{checkout.order.id}'],
254+
UrlGeneratorInterface::ABSOLUTE_URL
255+
)
256+
),
257+
'country_change' => urldecode(
258+
System::getContainer()->get('router')->generate(
259+
'richardhj.klarna_checkout.callback.country_change',
260+
['orderId' => '{checkout.order.id}'],
261+
UrlGeneratorInterface::ABSOLUTE_URL
262+
)
263+
),
264+
'validation' => System::getContainer()->get('router')->generate(
265+
'richardhj.klarna_checkout.callback.order_validation',
266+
[],
266267
UrlGeneratorInterface::ABSOLUTE_URL
267-
)
268-
),
269-
'validation' => System::getContainer()->get('router')->generate(
270-
'richardhj.klarna_checkout.callback.order_validation',
271-
[],
272-
UrlGeneratorInterface::ABSOLUTE_URL
268+
),
269+
],
270+
'billing_address' => $billingAddress,
271+
'shipping_address' => $shippingAddress,
272+
'shipping_options' => $this->shippingOptions(
273+
StringUtil::deserialize($this->iso_shipping_modules, true)
273274
),
274-
],
275-
'billing_address' => $billingAddress,
276-
'shipping_address' => $shippingAddress,
277-
'shipping_options' => $this->shippingOptions(
278-
StringUtil::deserialize($this->iso_shipping_modules, true)
279-
),
280-
'shipping_countries' => $this->config->getShippingCountries(),
281-
'external_payment_methods' => $this->externalPaymentMethods(),
282-
'options' => [
283-
'allow_separate_shipping_address' => [] !== $this->config->getShippingFields(),
284-
'color_button' => $this->klarna_color_button
285-
? '#' . $this->klarna_color_button
286-
: null,
287-
'color_button_text' => $this->klarna_color_button_text
288-
? '#' . $this->klarna_color_button_text
289-
: null,
290-
'color_checkbox' => $this->klarna_color_checkbox
291-
? '#' . $this->klarna_color_checkbox
292-
: null,
293-
'color_checkbox_checkmark' => $this->klarna_color_checkbox_checkmark
294-
? '#' . $this->klarna_color_checkbox_checkmark
295-
: null,
296-
'color_header' => $this->klarna_color_header
297-
? '#' . $this->klarna_color_header
298-
: null,
299-
'color_link' => $this->klarna_color_link
300-
? '#' . $this->klarna_color_link
301-
: null,
302-
'require_validate_callback_success' => true,
303-
'show_subtotal_detail' => (bool) $this->klarna_show_subtotal_detail,
304-
],
305-
'merchant_data' => http_build_query(['member' => $this->user->id ?? null]),
306-
];
307-
308-
if ($this->config->klarna_debug) {
309-
log_message(
310-
sprintf("New Klarna create request:\n\n%s\n", var_export($data, true)),
311-
'klarna_api.log'
312-
);
313-
}
314-
315-
$klarnaCheckout = new KlarnaOrder($connector);
316-
$klarnaCheckout->create($data);
275+
'shipping_countries' => $this->config->getShippingCountries(),
276+
'external_payment_methods' => $this->externalPaymentMethods(),
277+
'options' => [
278+
'allow_separate_shipping_address' => [] !== $this->config->getShippingFields(),
279+
'color_button' => $this->klarna_color_button
280+
? '#' . $this->klarna_color_button
281+
: null,
282+
'color_button_text' => $this->klarna_color_button_text
283+
? '#' . $this->klarna_color_button_text
284+
: null,
285+
'color_checkbox' => $this->klarna_color_checkbox
286+
? '#' . $this->klarna_color_checkbox
287+
: null,
288+
'color_checkbox_checkmark' => $this->klarna_color_checkbox_checkmark
289+
? '#' . $this->klarna_color_checkbox_checkmark
290+
: null,
291+
'color_header' => $this->klarna_color_header
292+
? '#' . $this->klarna_color_header
293+
: null,
294+
'color_link' => $this->klarna_color_link
295+
? '#' . $this->klarna_color_link
296+
: null,
297+
'require_validate_callback_success' => true,
298+
'show_subtotal_detail' => (bool) $this->klarna_show_subtotal_detail,
299+
],
300+
'merchant_data' => http_build_query(['member' => $this->user->id ?? null]),
301+
]
302+
);
317303

318304
$this->cart->klarna_checkout_module = $this->id;
319305
}

src/Resources/contao/dca/tl_iso_config.php

-10
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,3 @@
5959
],
6060
'sql' => "char(1) NOT NULL default ''",
6161
];
62-
63-
$GLOBALS['TL_DCA']['tl_iso_config']['fields']['klarna_debug'] = [
64-
'label' => &$GLOBALS['TL_LANG']['tl_iso_config']['klarna_debug'],
65-
'exclude' => true,
66-
'inputType' => 'checkbox',
67-
'eval' => [
68-
'tl_class' => 'w50',
69-
],
70-
'sql' => "char(1) NOT NULL default ''",
71-
];

src/Resources/contao/languages/en/tl_iso_config.php

-2
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,3 @@
2222
$GLOBALS['TL_LANG']['tl_iso_config']['klarna_api_password'][1] = 'Enter the API password that you can generate within the Klarna merchant portal.';
2323
$GLOBALS['TL_LANG']['tl_iso_config']['klarna_api_test'][0] = 'Test mode';
2424
$GLOBALS['TL_LANG']['tl_iso_config']['klarna_api_test'][1] = 'Tick the box to use the Klarna API-playground endpoint.';
25-
$GLOBALS['TL_LANG']['tl_iso_config']['klarna_debug'][0] = 'Debug';
26-
$GLOBALS['TL_LANG']['tl_iso_config']['klarna_debug'][1] = 'Log the data that is sent to Klarna to allow debugging.';

0 commit comments

Comments
 (0)