This repository has been archived by the owner on Oct 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Saikat Chakrabarti
committed
Nov 11, 2012
1 parent
c289cb2
commit cb84cd8
Showing
9 changed files
with
59 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## Step 1: Get it running | ||
|
||
In Step 1, we create a very checkout to purchase a single Oscare Wilde quote for $535.00. This demo uses the Stripe Button, which is a beta product but greatly simplifies creating your checkout. | ||
|
||
Before trying to run the code, sign up a Stripe account at [https://stripe.com/signup](https://stripe.com/signup). Then, grab your API keys from [https://manage.stripe.com/#account/apikeys](https://manage.stripe.com/#account/apikeys) and replace the placeholders in the code with them. | ||
|
||
Normally, you would then need to download the stripe-php client library from [https://stripe.com/docs/libraries](https://stripe.com/docs/libraries), but this source comes with the PHP library as a git submodule. | ||
|
||
This demo then uses the instructions in [https://stripe.com/docs/guides/php](https://stripe.com/docs/guides/php) and [https://stripe.com/docs/button](https://stripe.com/docs/guides/php) to create a simple checkout page. | ||
|
||
Once you get this demo running, make a payment, and then see your charge on your [dashboard](https://manage.stripe.com) to verify that it worked. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## Step 2: To err is human | ||
|
||
In this step, we add some simple error handling and show you how to debug the issue. | ||
|
||
To start, try running the demo from Step1 and making a payment with the card "4000000000000002" -- this is one of many cards that are available on [https://stripe.com/docs/testing](https://stripe.com/docs/testing) to reproduce specific errors. You'll notice that your program will error. | ||
|
||
To investigate the error, you have a couple of tools at your disposable. | ||
|
||
First, you can look at your own PHP logs. If you are running PHP through the built-in Apache on OS X, you can find these at /private/var/log/apache2/error_log. | ||
|
||
Second, you can look at the logs of requests you have made to Stripe. These are available in your Stripe dashboard at [https://manage.stripe.com/#logs](https://manage.stripe.com/#logs). | ||
|
||
You can also take a look at [https://stripe.com/docs/api#errors](https://stripe.com/docs/api#errors) to get a sense of possible errors Stripe may return to you. | ||
|
||
Once you get the code running in this tutorial, try making another purchase with a credit card with number "4000000000000002" -- you should get a nice message telling you your card was declined. Again, you can check your dashboard to see the failed payment. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Step 3: Factor in the refactoring | ||
|
||
We don't do much in this step except to break up our site into a few component pieces. This will help keep our code organized for the next few steps. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<?php | ||
require_once('../stripe/lib/Stripe.php'); | ||
$stripe = array( | ||
'secret_key' => 'sk_test_COES306BuVznThOZkMr8ibAa', | ||
'publishable_key' => 'pk_test_fRASYtf5gVfnrjeNS6Z0aqLW' | ||
'secret_key' => '<YOUR SECRET STRIPE API KEY>', | ||
'publishable_key' => '<YOUR PUBLISHABLE STRIPE API KEY>' | ||
); | ||
Stripe::setApiKey($stripe['secret_key']); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## Step 4: Customers | ||
|
||
Now that your Oscar Wilde quotes website is succeeding beyond your wildest dreams, you realize that the most avid Wilde fans keep coming back for quotes over and over again. Each time, they enter their credit card details in hopes of their next Wilde fix. | ||
|
||
But you can make this simpler for them. In this step, we show you how to create a Stripe customer object for your users the first time they purchase a quote with their credit card. Then, in the future, they can simply log in and pay with the card they have on file. | ||
|
||
In this step, we make a poor man's database in a text file located at /public/customers.txt. You should modify the code to save this elsewhere, or make sure that your PHP process can write to /public (and that that folder exists). To allow /public to be readable and writeable by any process (note: do this only if /public is only being used for the purposes of this demo), run: | ||
|
||
`chmod 777 /public` | ||
|
||
Once you get this code running, try purchasing a quote by signing up. Then, purchase another quote after logging in. You should see a customer in your Stripe dashboard with 2 payments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<?php | ||
require_once('../stripe/lib/Stripe.php'); | ||
$stripe = array( | ||
'secret_key' => 'sk_test_COES306BuVznThOZkMr8ibAa', | ||
'publishable_key' => 'pk_test_fRASYtf5gVfnrjeNS6Z0aqLW' | ||
'secret_key' => '<YOUR SECRET STRIPE API KEY>', | ||
'publishable_key' => '<YOUR PUBLISHABLE STRIPE API KEY>' | ||
); | ||
Stripe::setApiKey($stripe['secret_key']); | ||
?> |