Simplifying payments with Stripe
Upcoming SlideShare
Loading in...5
×
 

Simplifying payments with Stripe

on

  • 2,975 views

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

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 Musketeers.me, will be giving this talk. Check out their Kickstarter: http://kck.st/QjQZho

Statistics

Views

Total Views
2,975
Views on SlideShare
2,975
Embed Views
0

Actions

Likes
2
Downloads
40
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Simplifying payments with Stripe Simplifying payments with Stripe Presentation Transcript

  • Simplify payments using Stripe Oscar Merida oscar@musketeers.me
  • 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
  • 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
  • So we send customers away ©2012 Oscar Merida @omerida
  • 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
  • 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
  • Getting Started● Sign up at http://stripe.com/● Provides two sets of API keys ○ One set for testing transactions ○ One set for live transactions● Download the PHP client library ○ https://stripe.com/docs/libraries● Initialize the client require_once(./lib/Stripe.php); Stripe::setApiKey($my_public_key); ©2012 Oscar Merida @omerida
  • 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
  • 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
  • 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
  • Store & Retrieve Customers// create a new customer on stripe$customer = Stripe_Customer::create(array( "description" => "Customer for test@example.com", "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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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 https://stripe.com/docs/testing● View transaction logs on Stripe dashboard. ©2012 Oscar Merida @omerida
  • Other Stripe Features● CRUD methods for any object● Create, retrieve, pay Invoices.● Integrates with Freshbooks ©2012 Oscar Merida @omerida