简体   繁体   English

仅客户端集成付款后如何获得 Stripe 响应?

[英]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.

相关问题 支付成功后如何使用 Stripe payment_intent_data 发送邮件给客户? - How to use Stripe payment_intent_data to send email to client after succesful payment? 如何在服务器端验证 Stripe 支付成功 URL? - How to validate Stripe payment successUrl on server side? PayPal 客户端 JavaScript SDK 与服务器集成 - 设置支付金额 - PayPal client side JavaScript SDK with server integration - Set payment amount PayPal 服务器端集成未将付款详细信息传递给客户端 - PayPal Server Side integration not passing payment details to the client 如何从 webhook 获取 Stripe 的“payment_intent.suceded”响应以处理订单? - How do I get Stripe's "payment_intent.suceeded" response from the webhook in order to process an order? 第一次单击事件后,Stripe 客户端集成不会重定向 - Stripe client integration doesn't redirect after first click event 进行Stripe收费后获取JSON响应 - Get JSON response after a Stripe charge is made 万事达卡支付集成如何在完成支付后重定向到链接 - Mastercard payment integration how to redirect to a link after complete the payment 条带集成-带结帐重定向的付款方式 - Stripe integration - Payment Intent with checkout redirection 是否保证在 *after* 客户端智能支付按钮 .then() 之后触发 webhook? - Is it guarranteed that a webhook will be triggered *after* client-side Smart Payment Buttons .then()?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM