Saving credit card information for later charge with Stripe in Woocommerce

Viewed 6459

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?

2 Answers

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 ---,

                      })

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

Related