【问题标题】:Stripe Connect in Europe: Using Payment Intents to Charge Customers (React and Node js)欧洲的 Stripe Connect:使用支付意图向客户收费(React 和 Node js)
【发布时间】:2020-04-02 23:02:04
【问题描述】:

我正在设置一个直接收费的标准条带连接帐户。

这对我使用带有令牌的收费 api 非常有效,但对于我使用欧盟要求的支付意图 api 时不起作用。

以下代码用于获取客户端密码。

axios.post(`${process.env.REACT_APP_API}/paymentIntent`, stripeData).then(res => {console.log('paymentIntent res', res.data)
    let clientSecret = res.data.clientSecret
    this.props.stripe.createToken({}).then(res => {
        console.log('stripe token', res)
        if (!res.token) {
            this.setState({
                message:
                    "Invalid Credit Card. Your tickets have not been booked. You have not been charged"
            })
        }
        else{
            this.props.stripe.confirmCardPayment(
                clientSecret,
                {
                    payment_method: {
                        card: {
                            token: res.token.id
                        }
                    }
                }
            ).then( res => {console.log(res)})
        }
    })

      }

但我在控制台中收到以下错误:

Failed to load resource: the server responded with a status of 404 ()

error:
code: "resource_missing"
doc_url: "https://stripe.com/docs/error-codes/resource-missing"
message: "No such payment_intent: pi_1FnrwXLkWxxxxxxxxxxxxxxx"
param: "intent"
type: "invalid_request_error"

有几件事让我感到困惑。

  1. 我的 clientSecret 代码格式为:

pi_1FnrwXLkWxxxxxxxxxxxxxxx_secret_pGBi46eAzWxxxxxxxxxxxxxxx

从错误消息看来,它似乎只有一部分被发送到条带 api。这是导致错误的原因吗?

  1. 两个条纹答案建议在前端使用以下代码。

    var stripe = Stripe(STRIPE_PUBLIC_KEY, { stripeAccount: "{{ connected_account }}" })

如果这是正确的,我该如何调整此代码以进行反应以及将其放在组件中的什么位置?它现在给我一个错误。

参考1:Code=50 “No such payment_intent” when confirm payment intent for stripe

Ref2:Stripe Connect PaymentIntent error: No such payment_intent

  1. 在 Stripe 文档的其他地方,它说要使用 Payment Methods API 而不是带有 Payment Intents API 的令牌。我应该完全放弃使用令牌吗?

【问题讨论】:

    标签: node.js reactjs stripe-payments


    【解决方案1】:

    我已经找到了这些问题的答案(在 stripe 的帮助下)

    第一季度。这不是问题

    第三季度。不要将令牌与 Payment Intents API 一起使用。

    第二季度。不要使用文档中的代码。使用

    <StripeProvider
        apiKey={process.env.REACT_APP_API_STRIPE_PUBLISH}
        stripeAccount="{{ connected_account }}">
    

    当我对帐户进行硬编码时,这对我有用,但当我从后端获取连接的帐户 ID 并保存在 State 中时,它就不起作用了。我通过有条件地渲染组件来让它工作。我将状态中的连接帐户初始化为'' 并使用以下代码:

    {this.state.userEvent.organiser.stripeAccountID !== '' && 
        <StripeProvider
            apiKey={process.env.REACT_APP_API_STRIPE_PUBLISH}
            stripeAccount={this.state.userEvent.organiser.stripeAccountID}>
                <Elements>
                    <CheckoutForm
                        total={this.displayTotal()}
                        applicationFee={this.displayAdminFee()}
                        currency={this.state.userEvent.currency}
                        eventTitle={this.state.userEvent.title}
                        purchaser={this.state.purchaser}
                        userEvent={this.state.userEvent}
                        numTicketsSought={this.state.userEvent.numTicketsSought}    
                    />
                </Elements>
         </StripeProvider>
        }
    

    【讨论】:

      猜你喜欢
      • 2015-03-13
      • 1970-01-01
      • 2014-10-31
      • 2019-03-27
      • 1970-01-01
      • 1970-01-01
      • 2018-06-26
      • 1970-01-01
      • 2020-03-07
      相关资源
      最近更新 更多