Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Latest commit

 

History

History

2019-08-28-save-and-reuse-cards

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Saving and Reusing Cards (SCA) - Office Hours 2019-08-28

Walk through the basics of building a simple SCA compliant payment flow for saving cards and charging them later with the Stripe API and PHP following this guide.

🎬 Watch on YouTube

Getting Started

Follow these instructions to spin-up a copy of this demo project up on your local machine for development and testing purposes. This is meant to be a guide to show you how to go about building an SCA ready payment flow for saving and charging cards later when the customer is off session. Additionally, there's an example of how to bring a customer back "on session" to complete authentication, if for some reason the off session payment failed for authentication required.

Prerequisites

Step by step

  1. Configure your keys

Copy the example .env file and update those values with your Stripe API keys.

cp .env.example .env

Then, be sure to update the publishable key (pk_xxx) in client/index.html.

  1. Start the server
cd server/php
composer install
composer start
  1. Run the demo

Try using the test card 4000002760003184 which requires authentication for every transaction, will demonstrate the entire flow. Also, experiment with other cards like 4242424242424242 (no authentication required) and 4000002500003155 (authentication required to setup). For more test cards see https://stripe.com/docs/testing#cards.

Step 1: Saving card details

Browse as the customer to http://localhost:4242 and enter 4000002760003184 as the card number.

Step 2: Admin interface for charging later

Using the customer ID (cus_xxx) and payment method ID (pm_xxx) logged in Step 1, charge the customer from this admin interface: http://localhost:4242/admin

Step 3: Complete authentication

If off session payment fails because the transaction requires authentication, you'll want to bring the customer back on session to complete payment. Use the link from step 2 to view the "bring customer on session" page here: http://localhost:4242/complete?pi=pi_xxx&pm=pm_xxx

More Resources

Demo Saving and Charging Later

Demo Saving, Charging Later, and Bringing Customer On Session