Q&A
前提
Vue.js、Stripe を使用して支払いシステムを開発しています。
開発中にエラーが発生しました。
実現したいこと
Stripe API を取得したい
発生している問題・エラーメッセージ
Stripe: Unknown arguments ([object Object]). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options. (on API request to GET `/charges/{charge}`)
該当のソースコード
vueファイルのスクリプト部分です。
js
1<script> 2import { StripeCheckout } from '@vue-stripe/vue-stripe' 3// import Stripe from 'stripe' 4 5export default { 6 props: ['documentId', 'isLoggedIn'], 7 components: { 8 StripeCheckout 9 }, 10 data () { 11 this.publishableKey = 'pk_test_xxxxxxxxxxxxxxxxx' 12 return { 13 loading: false, 14 lineItems: [ 15 { 16 price: 'price_xxxxxxxx', // The id of the one-time price you created in your Stripe dashboard 17 quantity: 1 18 } 19 ], 20 successURL: `${location.protocol}//${location.host}/event-detail/${this.documentId}?${this.isLoggedIn}`, 21 cancelURL: 'https://www.google.com/?hl=ja' 22 } 23 }, 24 methods: { 25 submit () { 26 // You will be redirected to Stripe's secure checkout page 27 this.$refs.checkoutRef.redirectToCheckout() 28 } 29 }, 30 computed: { 31 currentUser () { 32 return this.$store.getters.cuurentUser 33 } 34 }, 35 created () { 36 const Stripe = require('stripe') 37 const stripe = Stripe('sk_test_xxxxxxxxxxxx') 38 39 var charge = stripe.charges.retrieve( 40 'ch_xxxxxxxx', 41 { 42 apiKey: 'sk_test_xxxxxxxxxxxx' 43 } 44 ) 45 charge.then((result) => { 46 console.log(result) 47 }).catch((error) => { 48 ////////////////////// ここでエラー 49 console.log(error.message) 50 }) 51 } 52} 53</script> 54
回答よろしくお願いします。
回答1件
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
2022/06/24 08:44 編集
退会済みユーザー
2022/06/24 08:48
2022/06/24 08:53
退会済みユーザー
2022/06/24 09:18 編集
2022/06/24 09:28 編集