Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scaling a Payments Platform

Scaling a Payments Platform

This talk is about some of the challenges we ran into building and scaling payments at Shopify, and the solutions we came up with to overcome them.

Avatar for John Duff

John Duff

May 24, 2018

More Decks by John Duff

Other Decks in Technology

Transcript

  1. ABOUT ME 2006 2011 2012 2013 2017 RUBY ON RAILS

    DEVELOPER SHOPIFY DEVELOPER API & INTEGRATIONS TEAM LEAD DIRECTOR OF ENGINEERING CONTRACTOR & CONSULTANT
  2. INTEGRATION Eway Authorize Purchase Capture Void Refund Linkpoint Authorize Purchase

    Capture Void Refund Paypal Authorize Purchase Capture Void Refund Purchase Capture Void Refund Authorize Authorize.NET
  3. [Active Merchant] abstracts as many parts as possible away from

    the user to offer a consistent interface across all supported gateways. “
  4. module ActiveMerchant # Base class for all ActiveMerchant gateway implementations.

    # Concrete gateway classes can and should implement include the following: # # * purchase(money, creditcard, options = {}) # * authorize(money, creditcard, options = {}) # * capture(money, authorization, options = {}) # * void(identification, options = {}) # * refund(money, identification, options = {}) class Gateway # The format of the amounts used by the gateway # :dollars => ’12.50’, :cents => '1250' class_inheritable_accessor :money_format self.money_format = :dollars # Does this gateway support credit cards of the passed type? def self.supports?(type) supported_cardtypes.include?(type.intern) end def self.supported_cardtypes [] end end end
  5. Defacto payment library for Ruby ACTIVE MERCHANT Support of the

    Open Source community Over a hundred payment providers
  6. PCI DSS OVERVIEW Maintain an Information Security Policy Regularly Monitor

    and Test Networks Implement Strong Access Control Measures Build and Maintain a Secure Network and Systems Protect Cardholder Data Maintain a Vulnerability Management Program
  7. Only store what you are allowed and really need PCI

    DSS OVERVIEW Encrypt transmission of all cardholder data tl;dr Protect cardholder data behind a secure network and restricted access
  8. Put as much of the system into scope as you

    possibly can and secure everything Every compliance consultant ever “
  9. Put as much of the system into scope as you

    possibly can and secure everything Every compliance consultant ever “ X
  10. 33 App Servers SCALE 2013 > 1000 Unicorn workers 5

    Job servers > 2000 Sales per minute > 50k RPM Average 45 ms response time 370 Job workers
  11. # Client def authorize(order) order.update_attribute(uuid: UUID.new) unless order.uuid.present? cardproxy.authorize(order.amount, uuid:

    order.uuid) end # CardProxy def create transaction = Transaction.find_or_create_by(uuid: params[:uuid]) if transaction.persisted? respond_with transaction.to_json, status: :conflict else transaction.amount = amount transaction.kind = transaction_type transaction.process! respond_with transaction.to_json, status: :created end end
  12. Idempotent requests so they can be retried SCALE Recovering vs

    preventing failures Move slower processes out of critical path
  13. 2012 2013 2013 2015 2017 CONNECT LAUNCHED ACCOUNT CONNECTION APPLICATION

    FEES TRANSACTION DATA BANK TRANSFERS API MANAGE & REFUND FEES FEES ON SUBSCRIPTIONS MANAGED ACCOUNTS MANY TO MANY PAYMENTS HOLDING FUNDS ACCOUNT DEBITS STRIPE CONNECT
  14. CHALLENGES Inconsistencies in totals Data not available in the APIs

    Values not broken down as we needed Keep your own records
  15. Basic hard code rules FRAUD DETECTION 2012 Depend on the

    payment processor Blacklist repeat attempts
  16. 10+ years of data WHY BUILD? We own the purchasing

    pipeline Investing in ML/AI Scalable
  17. Get Rating Orders History HDFS Spark Read History Fraud Model

    Feature Provider 1 Feature Provider N … Server
  18. If you build it, there will be fraud FRAUD DETECTION

    Leverage contextual data Fraud changes More @ https:/ /tinyurl.com/fraud-ml