@@ -183,23 +183,16 @@ protected function compile()
183
183
// Resume, just make sure the cart is up to date
184
184
$ klarnaCheckout = new KlarnaOrder ($ connector , $ klarnaOrderId );
185
185
try {
186
- $ data = [
186
+ $ klarnaCheckout ->update (
187
+ [
187
188
'order_amount ' => (int ) round ($ this ->cart ->getTotal () * 100 , 0 ),
188
189
'order_tax_amount ' => (int ) round (
189
190
($ this ->cart ->getTotal () - $ this ->cart ->getTaxFreeTotal ()) * 100 ,
190
191
0
191
192
),
192
193
'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
+ );
203
196
} catch (RequestException $ e ) {
204
197
$ klarnaCheckout = null ;
205
198
} catch (ConnectorException $ e ) {
@@ -222,98 +215,91 @@ protected function compile()
222
215
}
223
216
}
224
217
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 ,
232
227
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
- )
247
228
),
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
+ [],
266
267
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 )
273
274
),
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
+ );
317
303
318
304
$ this ->cart ->klarna_checkout_module = $ this ->id ;
319
305
}
0 commit comments