[英]How to use DIBS payment system with vuejs?
我有以下示例代碼,在一個 nuxtjs/vuejs 項目中
<template>
<v-app>
<div id="dibs-complete-checkout"></div>
</v-app>
</template>
<script>
export default {
head () {
return {
script: [
{ src: 'https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js' },
{ src: 'https://test.checkout.dibspayment.eu/v1/checkout.js?v=1' }
]
}
},
created () {
this.$axios.get('test/11').then((response) => {
var checkoutOptions = {
checkoutKey: response.data.checkOutKey,
paymentId: response.data.dibsPaymentId,
containerId: 'dibs-complete-checkout',
language: 'en-GB'
}
var checkout = new Dibs.Checkout(checkoutOptions)
checkout.on('payment-completed', function (response) {
})
checkout.on('pay-initialized', function (response) {
checkout.send('payment-order-finalized', true)
})
})
.catch((e) => {
console.error(e)
})
}
}
</script>
那里發生的事情是:
開發服務器在 http 上運行。
我收到幾個錯誤。 一是“Dibs未定義”
./pages/index.vueModule Error (from ./node_modules/eslint-loader/index.js):C:\git\ssfta_web\pages\index.vue 29:28 error 'Dibs' is not defined no-undef✖ 1 problem (1 error, 0 warnings)
這很奇怪,因為頁面加載並呈現在
另一個錯誤是
OPTIONS https://test.checkout.dibspayment.eu/api/v1/theming/checkout 401 (Unauthorized)
最后一個錯誤是
Access to XMLHttpRequest at 'https://test.checkout.dibspayment.eu/api/v1/theming/checkout' from origin 'http://10.0.75.1:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
我試過了:
當前情況的圖像
我真的沒有問題,我只是希望/懷疑我忘記了一些人可以發現的基本配置或細節
任何建議表示贊賞。
這周有這個問題。
就這個問題聯系了 Dibs 支持,離開了工作,第二天我回復了一封來自支持的電子郵件,其中包含我已經收到的 API 密鑰的副本,但是在再次測試我的項目(沒有任何更改)之后,這個錯誤神奇地發生了消失了,所以顯然這個問題是他們結束的事情。 假設我的鑰匙缺少正確的授權。
正確閱讀錯誤信息,是es lint錯誤
這樣做是為了解決它
/*eslint-disable */
var checkout = new Dibs.Checkout(this.checkoutData)
/* eslint-enable */
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.