1

So I am building an app that acts similarly to kickstarter/gofundme etc. in that once a price goal is met, it charges all the contributing customers. My process is, when a customer contributes towards the price goal I create a stripe customer and store their id:

    customer = stripe.Customer.create(
      email = <user_email>,
      source = <stripe_customer_token>
    )

I store this information in an array in my database. Once the price goal is met, I iterate over the array charging each customer using that initial card that stripe verified as legitimate.

    for customer in customer_array:
      charge = stripe.Charge.create(
        amount = <amount>,
        customer = <customer>,
      )

The problem I foresee is that sometimes these price goals will be up for weeks. On day 1, a customer could contribute and be verified by stripe as a legitimate card, but in 3 weeks that card could expire or be cancelled etc. Is there any way to run some sort of verification on a customer token before charging it to make sure it's still legitimate? I would hate to iterate over 9/10 customers in an array and charge them for being legit, then hit the final customer in the array with an invalid card. I am using stripe.js so hopefully there's a solution without incorporating the stripe api. Thanks.

Tennyx
  • 153
  • 10
  • There's not a great way to re-verify the card without actually attempting to charge it --- I'd simply try to iterate through each card and charge it. If it fails, start some dunning logic whereby you email or text the user and instruct them to update their card details. – duck Mar 25 '18 at 20:33

1 Answers1

1
\Stripe\Charge::create(array(
  "amount" => 2000,
  "currency" => "usd",
  "capture" => false,
  "source" => "tok_mastercard", 
  "description" => "Charge for avery.moore@example.com"
));

First Charge it with capture false, and capture it afterwards using the id returned from above. With this method, you could validate a card with more confident. In extreme case, for example credit card cancel or stolen, the bank can overrule all reserved fund command.

$ch = \Stripe\Charge::retrieve("ch_1C9s1N2eZvKYlo2Cmpk4KBgS");
$ch->capture();
Wils
  • 1,178
  • 8
  • 24