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

TakeOffConf 2014 - Payment revisited

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →

TakeOffConf 2014 - Payment revisited

Here are the slides I created for the TakeOffConf 2014 in Lille.
I've modify them a bit, to include missing contents that I cut off during the talk (yes, it was a bad idea).
The videos are hosted on YouTube, instead of locally, and have been re-recorded.

Videos are there:
https://youtube.googleapis.com/v/TgqEuayrYBY
https://youtube.googleapis.com/v/rso3Es06o_Q

Hope you'll enjoy them.

Avatar for Gregory Estrade

Gregory Estrade

January 30, 2014

Other Decks in Technology

Transcript

  1. FPGAs & Emulation Reverse-engineering (hardware and software) Software-wise: Support of

    the into Raspberry Pi QEMU Hardware-wise: understanding how these work... ... and recode the logic into a programmable device.
  2. e-Commerce ~ Payment Service Provider 5 million transactions per day

    ~600.000 POS in France alone - 1/2 of the French market
  3. Let's get to work! The path to success 1. Set

    up an online store. 2. Add the payment gateway. 3. Add mobile acceptance support. 4. Set up a marketplace. 5. ... 6. Profit!
  4. First step, set up an online store. TM TM I'll

    be using for this purpose. Spree
  5. Then write the gateway code. Basic setup $ c u

    r l - s S L h t t p s : / / g e t . r v m . i o | b a s h - s s t a b l e - - r u b y = 2 . 0 . 0 - - r a i l s $ g e m i n s t a l l s p r e e $ r a i l s n e w s t o r e $ s p r e e i n s t a l l s t o r e Adding the payment gateway We'll need to declare it into spree_gateway and add it to as well. active_merchant $ g i t c l o n e g i t : / / g i t h u b . c o m / S h o p i f y / a c t i v e _ m e r c h a n t . g i t $ c d . / a c t i v e _ m e r c h a n t $ b u n d l e i n s t a l l $ s c r i p t / g e n e r a t e g a t e w a y p a y z e n
  6. A quick tour of the API Sample request P O

    S T / p o s / 9 1 3 3 5 5 3 1 / c h a r g e s { " a m o u n t " : 4 2 9 9 , " c u r r e n c y " : " e u r " } Sample response H T T P / 1 . 1 2 0 1 C r e a t e d { " i d " : " 0 d e 4 4 b f 0 - 6 8 9 8 - 1 1 e 3 - 9 4 9 a - 0 8 0 0 2 0 0 c 9 a 6 6 " , " s t a t u s " : " i n c o m p l e t e " , . . . } A charge represents a sale/order. It may contains one or many transactions. Operations may be performed on both.
  7. Putting all together First, spree_gateway s p r e e

    _ g a t e w a y / l i b / s p r e e _ g a t e w a y / e n g i n e . r b a p p . c o n f i g . s p r e e . p a y m e n t _ m e t h o d s < < S p r e e : : G a t e w a y : : P a y z e n s p r e e _ g a t e w a y / a p p / m o d e l s / s p r e e / g a t e w a y / p a y z e n . r b m o d u l e S p r e e c l a s s G a t e w a y : : P a y z e n < G a t e w a y p r e f e r e n c e : l o g i n , : s t r i n g p r e f e r e n c e : c u r r e n c y , : s t r i n g , : d e f a u l t = > ' E U R ' d e f p r o v i d e r _ c l a s s A c t i v e M e r c h a n t : : B i l l i n g : : P a y z e n G a t e w a y e n d e n d e n d
  8. Putting all together Second, active_merchant a c t i v

    e _ m e r c h a n t / l i b / a c t i v e _ m e r c h a n t / b i l l i n g / g a t e w a y s / p a y z e n . r b h e a d e r s = { " C o n t e n t - T y p e " = > " a p p l i c a t i o n / j s o n " , " A u t h o r i z a t i o n " = > " B a s i c # { B a s e 6 4 . s t r i c t _ e n c o d e 6 4 ( o p t i o n s [ : l o g i n ] + ' : ' ) . s t r i p } " } u r l = " # { l i v e _ u r l } / c h a r g e s " b e g i n b o d y = p a r s e ( s s l _ p o s t ( u r l , p o s t _ d a t a ( a c t i o n , p a r a m e t e r s ) , h e a d e r s ) ) r e s c u e R e s p o n s e E r r o r = > e b o d y = p a r s e ( e . r e s p o n s e . b o d y ) e n d . . . c h a r g e _ s t a t u s = b o d y [ ' c h a r g e ' ] [ ' s t a t u s ' ] s u c c e s s = ( c h a r g e _ s t a t u s = = ' c o m p l e t e ' ) Done.
  9. OK, looks like we're quite ready, but... ... isn't there

    something missing ? ... the product we're going to sell, of course! Yeah, that's a meme from... 2004... Ten years ago... The internet was all in text mode at the time.
  10. A hot topic Yesterday, I found in a French economics

    newspaper yesterday about mobile acceptance. this article It states that a Digital Cash Register application will be provided... ... a cash register? Seriously ? We already have all we need on our website!!! Why bother with this ???
  11. Proposed use case 1. Shop on the website as usual,

    but from your smartphone. 2. Select a new payment method: Mobile POS. 3. Once selected, it will switch to a native app. 4. Process with card insertion and PIN entry on the device. 5. Upon success (or failure), check that the payment has been processed on the website.
  12. Under the hood 1. On checkout, initialize a payment with

    the order parameters (amount, currency) at the payment platform level. 2. User is prompted to click on a link with a custom URL protocol. 3. Clicking on it will start the associated mobile app. 4. The mobile app will then retrieve the order parameters from the payment platform. 5. The payment processing occurs, and an IPN is sent to the website.
  13. Implementation details Basic setup This time, we're using Spree's Billing

    integration engine, designed for off-site payment gateways . / a p p / m o d e l s / s p r e e / b i l l i n g _ i n t e g r a t i o n / p a y z e n / m o b i l e . r b p r e f e r e n c e : l o g i n , : s t r i n g p r e f e r e n c e : s h o p _ i d , : s t r i n g p r e f e r e n c e : c u r r e n c y , : s t r i n g , : d e f a u l t = > ' E U R ' d e f p r o v i d e r _ c l a s s A c t i v e M e r c h a n t : : B i l l i n g : : P a y z e n e n d d e f r e d i r e c t _ u r l ( o r d e r , o p t s = { } ) o p t s . m e r g e ! s e l f . p r e f e r e n c e s p a y z e n = s e l f . p r o v i d e r p a y z e n . p a y m e n t _ u r l ( o p t s ) e n d
  14. Implementation details Payment initialization . / l i b /

    a c t i v e _ m e r c h a n t / b i l l i n g / p a y z e n . r b d e f p a y m e n t _ u r l ( o p t s ) p o s t = { ' i n t e n t ' = > ' o f f - s i t e ' } p o s t . m e r g e ! { ' c a l l b a c k _ u r l ' = > c a l l b a c k _ u r l } p o s t . m e r g e ! o p t s . . . # R e t u r n s a n U R L w i t h t h e ' m p o s ' p r o t o c o l " m p o s : / / s t a r t / ? # { b o d y [ ' c h a r g e ' ] [ ' i d ' ] } " e n d . / s p r e e _ g a t e w a y / a p p / v i e w s / s p r e e / c h e c k o u t / p a y m e n t / _ m o b i l e . h t m l . e r b o p t s [ : a m o u n t ] = @ o r d e r . t o t a l o p t s [ : c u r r e n c y ] = @ o r d e r . c u r r e n c y . . . < a h r e f = " < % = p a y m e n t _ m e t h o d . r e d i r e c t _ u r l @ o r d e r , o p t s % > " > S t a r t p a y e m e n t o n t h e M o b i l e P O S < / a >
  15. Let's suppose for a moment that we find someone sharing

    the same interest in random flying things... It could be this guy...
  16. Let's set up the software Fortunately, there's a extension for

    this purpose. Spree github.com/jdutil/spree_drop_ship That's a "drop-shipping" extension (and there's also a marketplace extension).
  17. Not a big deal... ... However, be careful of the

    following issues: Governments are worried about tax escape in marketplaces. It's a 3-corner trust model (customer - marketplace - merchant). More on this later... Latest regulations don't help much. How to address them?
  18. Basically, two solutions: 1) Handle them yourself. That's basically what

    provides: a way to manage transfers between accounts. github.com/jdutil/spree_marketplace It supports (designed by Steve Klabnik). Balanced API 2) Have your Payment Service Provider handle them. It introduces a third (well, fourth) party in the payment process, especially if the shared account is managed by the company behind the service. It has to be compliant with all regulations, existing and yet to come.
  19. What's coming next? SEPA - Digital Wallets - Digital Currencies

    And why should I care about them? 1. They make the customer more confident in the purchase process. 2. Merchants concerns: make their customer happy, and avoid fraud. 3. Some of them make it easier to sell subscription-based services. This is all about trust models.