方法com.reactnativestripesdk。 Stripe SDKModule.confirmPayment,参数 paymentIntentClientSecret

问题描述 投票:0回答:1

我不知道如何解决这个问题。有人请帮助我!

在此输入图片描述

router.post("/create-payment-intent", async (req, res) => {
  const { items, user_id } = req.body;
  const customer = await stripe.customers.create();
  const ephemeralKey = await stripe.ephemeralKeys.create(
    { customer: customer.id },
    { apiVersion: '2024-04-10' }
  );
  try {
    const paymentIntent = await stripe.paymentIntents.create({
      amount: 1099,
      currency: 'usd',
      confirm: true,
      payment_method: 'pm_card_visa',
      payment_method_types: ['card'],
    });

    const response = {
      paymentIntent: paymentIntent.client_secret,
      ephemeralKey: ephemeralKey.secret,
      customer: customer.id,
      publishableKey: 'pk_test_51PA9vlRsfm3Ucs22ixDUZ8mt2Ki9E7WR4tSil67ONZD4dptsAwjVZ0J2IFNEEf0iHQhDNEaTT87f6mTD9dnY1lAW00TQcuO9MO'
    };

    return res.json(response);
  } catch (error) {
    console.error(error);
    return res.status(500).json({ error: 'An error occurred while creating Payment Intent' });
  }
});

我的编码非常非常糟糕,我不知道如何解决这个问题。

我知道我的代码在这里的某个地方是错误的或者丢失了很多东西。我可以确定我面临的错误,但我无法修复它,因为我不擅长编码,这是我的毕业项目。我希望有人能帮助我并为我编写代码以便能够修复错误!请!

在此输入图片描述

在此输入图片描述

在此输入图片描述

我不知道我的代码发生了什么,我无法修复它

在此输入代码

服务器报告有一个

secret_client
但应用程序像这样注销了

react-native stripe-payments
1个回答
1
投票

该错误表明您正在传递一个空参数,而应传递的是非空参数。 具体来说,

paymentIntent.client_secret

当您创建 paymentIntent 对象时,您应该收到 client_secret 作为响应的一部分。

{
  "id": "pi_3MtwBwLkdIwHu7ix28a3tqPa",
  "object": "payment_intent",
  "amount": 2000,
  "amount_capturable": 0,
  "amount_details": {
    "tip": {}
  },
  "amount_received": 0,
  "application": null,
  "application_fee_amount": null,
  "automatic_payment_methods": {
    "enabled": true
  },
  "canceled_at": null,
  "cancellation_reason": null,
  "capture_method": "automatic",
  "client_secret": "pi_3MtwBwLkdIwHu7ix28a3tqPa_secret_YrKJUKribcBjcG8HVhfZluoGH",  /// <----- HERE
  "confirmation_method": "automatic",
  "created": 1680800504,
  "currency": "usd",
  "customer": null,
  "description": null,
  "invoice": null,
  "last_payment_error": null,
  "latest_charge": null,
  "livemode": false,
  "metadata": {},
  "next_action": null,
  "on_behalf_of": null,
  "payment_method": null,
  "payment_method_options": {
    "card": {
      "installments": null,
      "mandate_options": null,
      "network": null,
      "request_three_d_secure": "automatic"
    },
    "link": {
      "persistent_token": null
    }
  },
  "payment_method_types": [
    "card",
    "link"
  ],
  "processing": null,
  "receipt_email": null,
  "review": null,
  "setup_future_usage": null,
  "shipping": null,
  "source": null,
  "statement_descriptor": null,
  "statement_descriptor_suffix": null,
  "status": "requires_payment_method",
  "transfer_data": null,
  "transfer_group": null
}

我将按照文档中概述的步骤操作,以确保您正确执行所有操作,因为您似乎没有正确返回响应或得到部分响应。

© www.soinside.com 2019 - 2024. All rights reserved.