Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Simplifying payments with Stripe


Published on

If you need to accept payments online, there is no shortage of options to choose from. Stripe is a relatively new service that simplifies the whole process.
You can be up and running in an evening. Stripe also makes it easy to setup recurring billing. All without storing sensitive credit card information on your server or emailing it around.
This presentation will look at what you need to get started and explore the PHP bindings for working with the Stripe API.

Oscar Merida, (@Omerida on Twitter) Founding Partner and Technical Lead at, will be giving this talk. Check out their Kickstarter:

  • Be the first to comment

Simplifying payments with Stripe

  1. 1. Simplify payments using Stripe Oscar Merida
  2. 2. Early payment services painful● Paylink & Payflow● Paypal● Poorly Designed APIs● No API standard.● Documentation was hard to find and use● Integration testing cumbersome. ©2012 Oscar Merida @omerida
  3. 3. Processing payments is complicated● Sign up for a merchant account or a payment gateway.● Pay Fees - Setup, Monthly, Transaction● Secure your forms/site with SSL● Ensure PCI compliance ○ Firewall where card data is stored ○ One function per server ○ Deploy anti-virus software & keep it current ○ Keep OS up to date ©2012 Oscar Merida @omerida
  4. 4. So we send customers away ©2012 Oscar Merida @omerida
  5. 5. Stripe simplifies payments● No merchant account or gateway required.● Pay 2.9% + 30 cents per charge.● Available in the U.S. and Canada.● Well documented API with hooks for PHP, Javascript, more● Pages w/payment forms must be HTTPS● Start accepting payments in minutes● Control the checkout & payment from start to finish. ©2012 Oscar Merida @omerida
  6. 6. Securely store customer data● Can verify CVC and Address information.● Collect demographic and marketing data on your site● Store sensitive card related data on Stripe ○ Certified PCI Level 1 Service Provider ©2012 Oscar Merida @omerida
  7. 7. Getting Started● Sign up at● Provides two sets of API keys ○ One set for testing transactions ○ One set for live transactions● Download the PHP client library ○● Initialize the client require_once(./lib/Stripe.php); Stripe::setApiKey($my_public_key); ©2012 Oscar Merida @omerida
  8. 8. Creating a Charge// charge amount must be integer in cents and > 50try { $cents = (int) ($order->after_tax * 100); $response = Stripe_Charge::create(array( "amount" => $cents, "currency" => "usd", "card" => array( number => $card, exp_month => $month, exp_year => $year, cvc => $cvc, name => $name, address_zip => $zip, ), "description" => sprintf("Submitting a payment") ));} catch (Stripe_CardError $ex) { $errors = $ex->getMessage();} ©2012 Oscar Merida @omerida
  9. 9. Catch exceptions on errorsCode Detailsincorrect_number The card number is incorrectinvalid_number The card number is not a valid credit card numberinvalid_expiry_month The cards expiration month is invalidinvalid_expiry_year The cards expiration year is invalidinvalid_cvc The cards security code is invalidexpired_card The card has expiredincorrect_cvc The cards security code is incorrectcard_declined The card was declined.missing There is no card on a customer that is being charged.processing_error An error occurred while processing the card. ©2012 Oscar Merida @omerida
  10. 10. Retrieve a successful chargeResponse has a unique id associated with asucessful charge. You can use this to pull upcharge details within your app.Stripe_Charge::retrieve("ch_xuykedHrYF75sx"); ©2012 Oscar Merida @omerida
  11. 11. Store & Retrieve Customers// create a new customer on stripe$customer = Stripe_Customer::create(array( "description" => "Customer for", "card" => array( number => 4111111111111111, exp_month => 03, exp_year => 2015, cvc => 123,)));// save stripe customer id for later$customer_id = $customer->id;// retrieve a customer from stripe$customer = Stripe_Customer::retrieve($customer_id); ©2012 Oscar Merida @omerida
  12. 12. Creating subscription plans// create a "Pro Membership" plan$plan = Stripe_Plan::create([ amount => 2500, // $25 in cents currency => usd, // required trial_period_days => 15, // first 15 days are free interval => month, // billing frequency month|year name => Pro Plan, id => pro]);// retrieve a plan$pro = Stripe_Plan::retrieve(pro); ©2012 Oscar Merida @omerida
  13. 13. Subscribing customers to plansCharge customers on a recurring basis$cupd = Stripe_Customer::retrieve($customer->stripe_id);$cupd->updateSubscription([ plan => pro, prorate => true, // prorate switching plans cancel_at_period_end => false, // keep charging forever quantity => 5 // bill them for 5 pro plan subscriptions]);// cancel a subcription$cupd = Stripe_Customer::retrieve($customer->stripe_id);$cupd->cancelSubscription(); ©2012 Oscar Merida @omerida
  14. 14. Creating a coupon for customersCoupons give a customer a percent off tosubscriptions or invoices.Stripe_Coupon::create([ percent_off => 20, duration => repeating, // first three month discount duration_in_months => 3, id = 20DCPHP, max_redemptions => 50, // limit usage to 50 people redeem_by => strtotime(2012-12-31 23:59:59), // UTC timestamp]); ©2012 Oscar Merida @omerida
  15. 15. Apply a coupon to subscription$cupd = Stripe_Customer::retrieve($customer->stripe_id);$cupd->updateSubscription([ plan => pro, prorate => true, // prorate switching plans cancel_at_period_end => false, // keep charging forever quantity => 5 // bill them for 5 pro plan subscriptions, coupon => 20DCPHP,]); ©2012 Oscar Merida @omerida
  16. 16. Events to hook into your applicationStripe can send events to your application via aPOST request with JSON data.You must respond with a 200 HTTP Status toindicate you received the webhook.● Send an email on charge.succeed events.● Notify user that a trial subscription will end. ©2012 Oscar Merida @omerida
  17. 17. Painless testing● Stripe provides test numbers for testing cards and scenarios ○ Test Visa, Mastercad, American Express numbers ○ Test address, zip, cvc check failures ○ Test card_declined, invalid expiration, invalid CVC ○ See● View transaction logs on Stripe dashboard. ©2012 Oscar Merida @omerida
  18. 18. Other Stripe Features● CRUD methods for any object● Create, retrieve, pay Invoices.● Integrates with Freshbooks ©2012 Oscar Merida @omerida