Adds account support
This commit is contained in:
@@ -19,10 +19,7 @@ export default async (req, res) => {
|
||||
await klarnaProviderService.acknowledgeOrder(klarnaOrder.order_id, order._id)
|
||||
} catch (err) {
|
||||
if (err.type === MeudsaError.Types.NOT_FOUND) {
|
||||
let cart = await cartService.retrieve(cartId)
|
||||
const method = cart.payment_sessions.find(p => p.provider_id === "klarna")
|
||||
cart = await cartService.setPaymentMethod(cart._id, method)
|
||||
|
||||
const cart = await cartService.retrieve(cartId)
|
||||
const order = await orderService.createFromCart(cart)
|
||||
await klarnaProviderService.acknowledgeOrder(klarnaOrder.order_id, order._id)
|
||||
}
|
||||
@@ -30,6 +27,7 @@ export default async (req, res) => {
|
||||
|
||||
res.sendStatus(200)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class KlarnaProviderService extends PaymentService {
|
||||
0
|
||||
|
||||
// Withdraw discount from the total item amount
|
||||
const quantity = item.content.quantity
|
||||
const quantity = item.quantity
|
||||
const unit_price = item.content.unit_price * 100 * (taxRate + 1)
|
||||
const total_discount_amount = itemDiscount * (taxRate + 1) * 100
|
||||
const total_amount = unit_price * quantity - total_discount_amount
|
||||
@@ -155,7 +155,7 @@ class KlarnaProviderService extends PaymentService {
|
||||
terms: this.options_.merchant_urls.terms,
|
||||
checkout: this.options_.merchant_urls.checkout,
|
||||
confirmation: this.options_.merchant_urls.confirmation,
|
||||
push: `${this.backendUrl_}/klarna/push`,
|
||||
push: `${this.backendUrl_}/klarna/push?klarna_order_id={checkout.order_id}`,
|
||||
shipping_option_update: `${this.backendUrl_}/klarna/shipping`,
|
||||
address_update: `${this.backendUrl_}/klarna/address`,
|
||||
}
|
||||
@@ -274,6 +274,7 @@ class KlarnaProviderService extends PaymentService {
|
||||
)
|
||||
return klarnaOrderId
|
||||
} catch (error) {
|
||||
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user