2

We have a Wordpress web-shop and we are using the WooCommerce plugin and Stripe. We need to delay charging the customers until the physical items are shipped but Stripe doesn't have that functionality. We've been told to use saving-cards but we don't understand how to set this up on our backend considering that we've been using pre-built tools so far. Any idea of the integration? How does this process work?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
andrea
  • 39
  • 2
  • 8
  • 2
    This will involve considerable amount of customisation. You will need to create custom plugin of customise stripe plugin to enable the card saving functionality. Further more, you will need to create functionality to enable charging the saved card (either manually or automatic) after the physical items are shipped. If are allowing guest checkout (i.e. allowing visitors to place order without creating account on your website), then will also have to store their details and associate the saved card details with their record. Hope this gives you some direction for further investigation. – zipkundan Nov 15 '18 at 13:52
  • Hmm, thank you for your comment but there must be a easier way to do something like this considering that many of the web-shops out there have it up in running – andrea Nov 15 '18 at 15:00

2 Answers2

1

to do this:

You create a customer and a charge but specify not to capture the charge

You then use the saved customer token to charge the customer when goods are shipped.

This isn't in php but something like this:

customer = Stripe::Customer.create({
              :source  => 'tok_1234',
              :email => params[:stripeEmail],
            })

            charge = Stripe::Charge.create({
              amount: @amount,
              currency: 'usd',
              customer: customer.id,
              capture: false,
          })

note: capture: false...

Then when you update the order, when goods are shipped:

charge = Stripe::Charge.create({
                        :amount      => @amount,
                        :description => 'Rails Stripe customer',
                        :currency    => 'usd',
                        :customer => #where you save the customer token ---,

                      })
uno
  • 1,421
  • 12
  • 38
  • Hi! Thanks for the tip. How does it work when a customer creates an order on wordpress? How do I change it to create automatically a customer and not a charge? So far I can only do it manually using Stripe API – andrea Nov 16 '18 at 08:29
  • The code above does that. The charge is there just to attach a credit/debit to the customer. Essentially you are only creating a customer but you don't want people buying stuff with no credit card or no funds in their credit card.....you don't capture the payment though. Stripe will only validate they have the funds in their account to make the order. then under your update when the order is sent, you then create the charge without the "capture: false" --- without specifying the capture, it will automatically capture it. .... – uno Nov 16 '18 at 09:29
  • You may be asking how the it even charges after when you sent; you will need to store the stripeToken which is the customer id as i commented out "#where you save the customer token ---, ..." – uno Nov 16 '18 at 09:29
0

welcome to StackOverflow!

While Stripe does not allow to save cards directly, you can store a tokenized anonymous version of the card and use the token to charge the card anytime.

The card's data are stored remotely by Stripe and the system is able to match the card with the token.

You can find more information here: https://stripe.com/docs/saving-cards (as you know) and here https://stripe.com/docs/charges

This topic may be also useful: Stripe Payment: Save token and customer and make payment later from token

Hope it helps.

Cheers, Francesco

FrancescoCarlucci
  • 1,570
  • 12
  • 13