Skip to content

Commit

Permalink
Use processURLAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
benjick committed Jun 4, 2020
1 parent b849fd8 commit 8d94b1b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .docker/frontend/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"height": "height",
"length": "length"
},
"create": "http://api:8080/api/ext/payment-klarna-bridge/create-or-update-order?cartId={{cartId}}",
"confirmation": "http://api:8080/api/ext/payment-klarna-bridge/order-id?sid={{sid}}",
"validate_order": "http://api:8080/api/ext/payment-klarna-bridge/validate-kco-callback?cartId={{cartId}}",
"create": "/api/ext/payment-klarna-bridge/create-or-update-order?cartId={{cartId}}",
"confirmation": "/api/ext/payment-klarna-bridge/order-id?sid={{sid}}",
"validate_order": "/api/ext/payment-klarna-bridge/validate-kco-callback?cartId={{cartId}}",
"showShippingOptions": true,
"options": {
"additional_checkboxes": [
Expand Down
3 changes: 2 additions & 1 deletion packages/payment-klarna/hooks/afterRegistration.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TaskQueue } from '@vue-storefront/core/lib/sync'
import { processURLAddress } from '@vue-storefront/core/helpers';
import { defaultPlugins, addPlugin } from '../plugins'

const execute = (url, body) => TaskQueue.execute({
Expand All @@ -17,7 +18,7 @@ export function afterRegistration ({ Vue, isServer, config, store }) {
addPlugin(plugin)
})
if (config.klarna.validate_order) {
const url = config.klarna.validate_order
const url = processURLAddress(config.klarna.validate_order)
Vue.prototype.$bus.$on('klarna-event-order_total_change', () => {
const { orderId } = store.state.kco.checkout
if (url && orderId) {
Expand Down
5 changes: 3 additions & 2 deletions packages/payment-klarna/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import config from 'config'
import RootState from '@vue-storefront/core/types/RootState'
import Vue from 'vue'
import { currentStoreView } from '@vue-storefront/core/lib/multistore'
import { processURLAddress } from '@vue-storefront/core/helpers';
import { plugins, addPlugin } from '../plugins'

const execute = (url, method = 'GET', body = null) => TaskQueue.execute({
Expand Down Expand Up @@ -67,7 +68,7 @@ export const actions: ActionTree<KlarnaState, RootState> = {
const storeCode = currentStoreView().storeCode
const dataSourceStoreCode = storeCode && config.storeViews[storeCode] && config.storeViews[storeCode].dataSourceStoreCode
const { snippet, ...result }: any = await dispatch('klarnaCreateOrder', {
url: config.klarna.create || config.klarna.endpoint,
url: processURLAddress(config.klarna.create || config.klarna.endpoint),
body: {
order,
storeCode,
Expand All @@ -89,7 +90,7 @@ export const actions: ActionTree<KlarnaState, RootState> = {
}
},
async fetchOrder (context, sid: string) {
const url = config.klarna.confirmation.replace('{{sid}}', sid)
const url = processURLAddress(config.klarna.confirmation.replace('{{sid}}', sid))
const { result }: any = await execute(url)
return result
},
Expand Down

0 comments on commit 8d94b1b

Please sign in to comment.