Home > Enterprise >  stripe paymentRequest with total amount 0$
stripe paymentRequest with total amount 0$

Time:09-26

when I'm trying to make payment with payment request button I need to set 0$ amount when creating payment intent for it, but I can't, cause for creating payment intent stripe requires min 0.50$. I need it cause I'm using it for metered subscription type and don't have to charge client when subscribing. I found solution to refund after successfully subscription, but I don't like it. I'm creating payment_intent with this api

app.post('/api/client-secret', async (req, res) => {
  try {
    const { currency, amount } = req.body;
    console.log(req.body)
    const paymentIntent = await stripe.paymentIntents.create({
      amount,
      currency: 'usd',
      payment_method_types: ['card'],
    });
  
    res.json({ clientSecret: paymentIntent.client_secret });
  } catch (error) {
    console.log("error1", error)
  }
});

maybe there is other way or method to create client_secret for stripe.paymentRequest()

CodePudding user response:

The payment_intent object has a field called capture_method. You can set this manual, in which case the payment is not immediately captured by stripe. Pay attention to the parenthesis:

(Not all payment methods support this)


On a different note, if this is a subscription, then why not use the subscription api or even better, sessions. I suggest sessions because it handles all sorts of issues that may arise during a transaction, and all you need to do is wait for the session to complete, and everything will be taken care of.

Also note that the price object (which represents the items you are selling) comes with a field called usage_type which allows you specify that the item is metered, so stripe can handle the billing for you if someone purchases that item.

The stripe api is vast and well documented, so I hope this answer helps you discover a solution quickly.

CodePudding user response:

If you're not charging the user upfront, you should use SetupIntents to save and attach card details to the Customer for charging them in the future — when they’re offline : https://stripe.com/docs/payments/save-and-reuse

  • Related