Skip to content

Commit

Permalink
feat(module): Export method code
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kozachek committed Nov 4, 2019
1 parent 0a16870 commit c6627de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 4 additions & 5 deletions hooks/afterRegistration.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import Microform from '../components/Microform.vue'
import { adjustMultistoreApiUrl } from '@vue-storefront/core/lib/multistore'

import { METHOD_CODE } from '../index'

export function afterRegistration({ Vue, config, store, isServer }) {
const CURRENT_METHOD_CODE = config.cybersource.backend_method_code || 'cybersource'
let correctPaymentMethod = false
let componentInstance = null

Expand Down Expand Up @@ -57,12 +56,12 @@ export function afterRegistration({ Vue, config, store, isServer }) {
// Update the methods
let paymentMethodConfig = {
'title': 'Cybersource',
'code': CURRENT_METHOD_CODE,
'code': METHOD_CODE,
'cost': 0,
'costInclTax': 0,
'default': false,
'offline': false,
'is_server_method': config.cybersource.backend_method_code ? true : false
'is_server_method': false
}
store.dispatch('payment/addMethod', paymentMethodConfig)

Expand All @@ -78,7 +77,7 @@ export function afterRegistration({ Vue, config, store, isServer }) {

// Mount the microform component when required.
Vue.prototype.$bus.$on('checkout-payment-method-changed', (paymentMethodCode) => {
if (paymentMethodCode === CURRENT_METHOD_CODE) {
if (paymentMethodCode === METHOD_CODE) {
correctPaymentMethod = true

const Component = Vue.extend(Microform)
Expand Down
4 changes: 3 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import config from 'config'
import { VueStorefrontModule, VueStorefrontModuleConfig } from '@vue-storefront/core/lib/module'
import { afterRegistration } from './hooks/afterRegistration'
import { module } from './store'

const KEY = 'payment-cybersource'
export const KEY = 'payment-cybersource'
export const METHOD_CODE = config.cybersource.backend_method_code || KEY

const moduleConfig: VueStorefrontModuleConfig = {
key: KEY,
Expand Down

0 comments on commit c6627de

Please sign in to comment.