Rune FS
Rune FS

Reputation: 21742

How do I do partial capture with stripe

I've tried to do partial captures with stripe.

First I authorize 12000 then I capture part with

curl https://api.stripe.com/v1/charges/{chargeId}/capture \
     -u key 
     -d amount=250 
     -X POST 

and immediately after (for testing) I do exactly the same

    curl https://api.stripe.com/v1/charges/{chargeId}/capture \
     -u key 
     -d amount=250 
     -X POST 

first one is a success but the second one fails with

{
  "error": {
    "type": "invalid_request_error",
    "message": "Charge ch_18092DHwc58lFNepWa5maML7 has already been captured."
  }
}

what am I doing wrong since I can't capture the remaining funds

p.s. I started doing this in stripe.net where I had the same issue. Then to rule out stripe.net as the source of the error I tried directly in the terminal

Upvotes: 3

Views: 5068

Answers (2)

Alex
Alex

Reputation: 2915

You can only capture an authorized transaction once - even if it's just partially captured. According to Stripe support:

If you want to charge less than the initial amount, you can pass in the amount parameter and we’ll refund the rest back to the customer.

(emphasis added)

You will notice on the dashboard that a partially captured transaction shows the remaining funds as refunded.

An alternative would be to save the customer's card and create charges as needed.

Upvotes: 5

castletheperson
castletheperson

Reputation: 33496

What you are doing is called "auth and capture", where you authorize now, and then charge the credit card later.

To authorize, set capture to false on the first request.

On the second request, setting the amount should not be done unless you want to lower the price and refund the customer.

Upvotes: 1

Related Questions