[英]Stripe with Vue.js
I'm trying to get Stripe working with Vue but am having some difficulties.我正在尝试让 Stripe 与 Vue 一起工作,但遇到了一些困难。
So, I'm importing it in the head of my html file:所以,我将它导入到我的 html 文件的头部:
<!-- STRIPE -->
<script src="https://js.stripe.com/v3/"></script>
After a button is pressed, I run:按下按钮后,我运行:
const stripe = Stripe('pk_test_xxxxxxxxxxxxxxxxxx');
stripe.redirectToCheckout({
items: [{sku: 'sku_xxxxx', quantity: 1}],
successUrl: 'http://localhost:5000/success',
cancelUrl: 'http://localhost:5000/canceled',
})
But I get a Stripe is not defined.但我得到一个 Stripe 没有定义。
I also tried importing it from npm like Node.我也尝试从 npm 像 Node.js 一样导入它。
import Stripe from 'stripe'
const stripe = Stripe('pk_test_xxxxxxxxxxxxxxxxxx');
stripe.redirectToCheckout({
items: [{sku: 'sku_xxxxx', quantity: 1}],
successUrl: 'http://localhost:5000/success',
cancelUrl: 'http://localhost:5000/canceled',
})
I don't get Stripe is not defined but I get a TypeError: stripe.redirectToCheckout is not a function
我没有得到 Stripe is not defined 但我得到一个
TypeError: stripe.redirectToCheckout is not a function
I'm trying to get Stripe working with Vue but am having some difficulties.我正在尝试让 Stripe 与 Vue 一起工作,但遇到了一些困难。
So, I'm importing it in the head of my html file:所以,我将它导入到我的 html 文件的头部:
<!-- STRIPE -->
<script src="https://js.stripe.com/v3/"></script>
After a button is pressed, I run:按下按钮后,我运行:
const stripe = Stripe('pk_test_xxxxxxxxxxxxxxxxxx');
stripe.redirectToCheckout({
items: [{sku: 'sku_xxxxx', quantity: 1}],
successUrl: 'http://localhost:5000/success',
cancelUrl: 'http://localhost:5000/canceled',
})
But I get a Stripe is not defined.但我得到一个 Stripe 没有定义。
I also tried importing it from npm like Node.我也尝试从 npm 像 Node.js 一样导入它。
import Stripe from 'stripe'
const stripe = Stripe('pk_test_xxxxxxxxxxxxxxxxxx');
stripe.redirectToCheckout({
items: [{sku: 'sku_xxxxx', quantity: 1}],
successUrl: 'http://localhost:5000/success',
cancelUrl: 'http://localhost:5000/canceled',
})
I don't get Stripe is not defined but I get a TypeError: stripe.redirectToCheckout is not a function
我没有得到 Stripe is not defined 但我得到一个
TypeError: stripe.redirectToCheckout is not a function
I'm trying to get Stripe working with Vue but am having some difficulties.我正在尝试让 Stripe 与 Vue 一起工作,但遇到了一些困难。
So, I'm importing it in the head of my html file:所以,我将它导入到我的 html 文件的头部:
<!-- STRIPE -->
<script src="https://js.stripe.com/v3/"></script>
After a button is pressed, I run:按下按钮后,我运行:
const stripe = Stripe('pk_test_xxxxxxxxxxxxxxxxxx');
stripe.redirectToCheckout({
items: [{sku: 'sku_xxxxx', quantity: 1}],
successUrl: 'http://localhost:5000/success',
cancelUrl: 'http://localhost:5000/canceled',
})
But I get a Stripe is not defined.但我得到一个 Stripe 没有定义。
I also tried importing it from npm like Node.我也尝试从 npm 像 Node.js 一样导入它。
import Stripe from 'stripe'
const stripe = Stripe('pk_test_xxxxxxxxxxxxxxxxxx');
stripe.redirectToCheckout({
items: [{sku: 'sku_xxxxx', quantity: 1}],
successUrl: 'http://localhost:5000/success',
cancelUrl: 'http://localhost:5000/canceled',
})
I don't get Stripe is not defined but I get a TypeError: stripe.redirectToCheckout is not a function
我没有得到 Stripe is not defined 但我得到一个
TypeError: stripe.redirectToCheckout is not a function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.