小编Sta*_*soz的帖子

您无法使用 PaymentMethod 创建费用。请改用支付意图 API

用于从条带获取令牌并将其发送到后端的客户端代码的一部分

const cardElement = elements.getElement(CardElement);
const {error, paymentMethod} = await stripe.createPaymentMethod({
   type: 'card',
   card: cardElement,
});

    try {
      const { id } = paymentMethod;
      console.log(id)
      const response = await axios.post(
        "https://localhost:44325/api/Payment",
        {
          token: id,
        }
      );

  
    } catch (error) {
      console.log("CheckoutForm.js 28 | ", error);
    }
  } 
Run Code Online (Sandbox Code Playgroud)

后端

public async Task Test(string token)
        {
            StripeConfiguration.ApiKey = "SecretKey";
        var options = new ChargeCreateOptions()
        {
            Amount = 12345,
            Currency = "usd",

            Description = "Donation from me",
            Source = token
        };
        var service …
Run Code Online (Sandbox Code Playgroud)

.net stripe-payments reactjs

2
推荐指数
1
解决办法
3084
查看次数

标签 统计

.net ×1

reactjs ×1

stripe-payments ×1