3

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

Rune FS
  • 21,497
  • 7
  • 62
  • 96

2 Answers2

5

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.

Alex
  • 2,795
  • 3
  • 21
  • 21
  • 1
    Yeah I got that far too. I was just think that since this is such a general issue when it comes to e-commerce. They must have support for it somehow – Rune FS Apr 15 '16 at 06:18
1

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.

4castle
  • 32,613
  • 11
  • 69
  • 106
  • I have no problems with the authorization, nor the first partial capture. It's when I tried to capture the remaining funds I run in to troubles – Rune FS Apr 14 '16 at 12:16
  • I updated my answer. Don't set `amount` on the second request. – 4castle Apr 14 '16 at 12:17
  • I want to do a subsequent partial capture. The flow I need is like this: Auth follew by one or many captures. The approach would work even in the case where I wanted to capture the full amount second time around. The error is the same – Rune FS Apr 14 '16 at 12:24
  • What do you mean? A partial capture only involves two requests: the first places a hold on the funds, the second is a capture on the funds. – 4castle Apr 14 '16 at 12:26
  • no that would be a full capture. A partial capture is when you capture _part_ of the reserved funds – Rune FS Apr 14 '16 at 12:27
  • I'm not familiar with it, but try looking up how people do subscriptions. That would be a similar process. – 4castle Apr 14 '16 at 12:35