[英]How to get Stripe response after payment with client-side-only-integration?
I've got this simple component, which sends a client-side-only
payment order to my stripe account.我有这个简单的组件,它向我的条带帐户发送一个client-side-only
付款订单。 Everything works but I can't figure out how to get a response
/ token
from stripe with the order information, which I can send to my backend.一切正常,但我不知道如何从带有订单信息的条带中获取response
/ token
,我可以将其发送到我的后端。
<script setup>
import {onMounted} from "vue";
let stripe = null
onMounted(async () => {
stripe = Stripe(import.meta.env.VITE_STRIPE_PUBLISHABLE_KEY)
})
const redirect = () => {
stripe.redirectToCheckout({
successUrl: 'http://localhost:8000/success',
cancelUrl: 'http://localhost:8000/cancel',
lineItems: [
{
price: import.meta.env.VITE_PHOTO_PRICE,
quantity: 2
}
],
mode: 'payment'
})
}
</script>
<template>
<div id="checkout" class="checkout">
<button @click="redirect">Pay now!</button>
</div>
</template>
Is there a reference in the stripe checkout docs or something?条纹结帐文档或其他内容中是否有参考?
The integration path you chose here is called client-only Checkout but this was deprecated a couple of years ago by Stripe and is mostly discouraged at this point.您在此处选择的集成路径称为仅限客户端的 Checkout,但几年前 Stripe 已弃用此方法,此时大多不鼓励使用。 Instead, Stripe built their new product called Payment Links which is even easier.相反,Stripe 构建了名为Payment Links的新产品,这更加容易。 You configure what you want to sell in the Dashboard, get a URL back looking like https://buy.stripe.com/123ABC456
and you can share that URL with any of your customers for them to pay you.您在仪表板中配置您想要销售的产品,获取一个类似于https://buy.stripe.com/123ABC456
的 URL,然后您可以与您的任何客户共享该 URL,让他们向您付款。
To focus on your specific question though, there is no "order id" or anything else returned by redirectToCheckout()
.但是,要专注于您的特定问题,没有“订单 ID”或redirectToCheckout()
返回的任何其他内容。 The goal is this call is to send your customer to Stripe's hosted payment page immediately.这个电话的目标是立即将您的客户发送到 Stripe 的托管支付页面。 If you need to map this future payment with a specific customer or order, you should use the client_reference_id
property associated with a Checkout Session
.如果您需要将此未来付款映射到特定客户或订单,则应使用与 Checkout Session
关联的client_reference_id
属性。 You can set it client-side as clientReferenceId
in your call and it will be set on the Session itself for you.您可以在调用中将其设置为客户端的clientReferenceId
,它将为您在 Session 本身上设置。 When you get the checkout.session.completed
event sent to your webhook handler, or after the redirect from Checkout, you'll be able to map that id to whatever you have stored internally in your own system/database.当您将checkout.session.completed
事件发送到您的 webhook 处理程序时,或者在从 Checkout 重定向之后,您将能够将该 id 映射到您在自己的系统/数据库中内部存储的任何内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.