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

When making money becomes a headache

When making money becomes a headache

When things go right and our product starts making money everyone is happy, but sometimes this means the start of the nightmare for people working with payments.

Let's not sugar coat it. In this talk you'll learn about some where thing went terribly wrong, some of them involved loosing money. Stories of stuff that can easily get overlooked, about the most common mistakes when working with payments and things you probably won't consider until shit hits the fan. All of this so that you don't run into the same problems and don't have to learn those lessons the hard way.

Presented at: wroc_love.rb 2016

92d08794b535e41a4082c57ea547546e?s=128

Sebastian Sogamoso

March 13, 2016
Tweet

Transcript

  1. Dealing with payments

  2. Sebastián Sogamoso @sebasoga

  3. None
  4. None
  5. Story time

  6. When making money becomes a ache head

  7. None
  8. None
  9. None
  10. Requirements

  11. Payment gateway

  12. Our system

  13. Our system

  14. Our system Payment Gateway

  15. Our system Payment Gateway

  16. Our system Payment Gateway Payment Processor

  17. Our system Payment Gateway Payment Processor 1 Payment Processor 2

  18. Our system Payment Gateway Payment Processor

  19. Our system Payment Gateway Payment Processor

  20. Our system Payment Gateway Payment Processor Card’s Brand

  21. Our system Payment Gateway Payment Processor Card Issuing Bank Marchant’s

    Bank Card’s Brand
  22. Our system Payment Gateway Marchant’s Bank

  23. Our system Payment Gateway

  24. None
  25. None
  26. Product launch

  27. Not quite as fast

  28. Not quite as fast Requests timeout

  29. Not quite as fast Requests timeout Background workers to the

    rescue
  30. Client’s browser Web application

  31. Client’s browser Web application Background Worker

  32. Client’s browser Web application Background Worker

  33. Client’s browser Web application Background Worker Creates the user Payment

    Gateway
  34. Client’s browser Web application Background Worker Background Worker Payment Gateway

    Add card to user
  35. Client’s browser Web application Background Worker Background Worker Payment Gateway

    Charges user Background Worker
  36. None
  37. Atomic operations

  38. ActiveRecord.transaction do company.charge(price + fee) computer_owner.pay(price) end

  39. PaymentGateway.transaction do renter.charge!(amount: 120) owner.pay!(amount: 100) end

  40. None
  41. to a 3rd party Coupling

  42. Adapter pattern

  43. Business Logic Payment Gateway Logic

  44. Business Logic Payment Gateway 1 Payment Gateway 2

  45. Business Logic Payment Gateway 1 Payment Gateway 2

  46. None
  47. Payment gateway Own system Pay user Ok

  48. Payment gateway Own system Pay user Ok Payment result Ok

  49. None
  50. None
  51. Monitoring & Alerts

  52. Current state & History

  53. None
  54. @sebasoga Thanks!