<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Clément Salaün on Medium]]></title>
        <description><![CDATA[Stories by Clément Salaün on Medium]]></description>
        <link>https://medium.com/@superzamp?source=rss-eed605d08e6a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mTZO3HUBkYpMdoINflWFXg.jpeg</url>
            <title>Stories by Clément Salaün on Medium</title>
            <link>https://medium.com/@superzamp?source=rss-eed605d08e6a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 21:22:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@superzamp/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Your balance is $0.30000000004]]></title>
            <link>https://medium.com/selency-tech-product/your-balance-is-0-30000000004-b6f7870bd32e?source=rss-eed605d08e6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6f7870bd32e</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[reliability]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[fintech]]></category>
            <dc:creator><![CDATA[Clément Salaün]]></dc:creator>
            <pubDate>Mon, 17 Feb 2020 09:25:34 GMT</pubDate>
            <atom:updated>2020-02-25T13:10:58.448Z</atom:updated>
            <content:encoded><![CDATA[<h4>Common problems found in money-handling software</h4><p>If you write software that happens to manage money, I feel you. As an industry, we too often don’t hold ourselves to very high standards regarding reliability of the things we build. While an <a href="https://xkcd.com/2030/">elevator is practically incapable of failing</a>, things going wrong in software is business as usual. As a result, software that manages money if often built on flaky foundations.</p><p>In this article we attempt to build an inventory of frequent issues found in financial software, an inventory that you can use to check your current system against.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*dKYG-4yTrSkYBqLGWcXhxA.png" /><figcaption>Sweetest spot on earth in the center — will rent</figcaption></figure><h3>Arithmetical errors</h3><h4>Floating point</h4><p>Let’s start with the obvious: the first problem that I perhaps encounter the most is the use of floating point numbers for the manipulation and storage of money amounts. Why is that a problem? Well, if you open a javascript console and execute the following:</p><pre>&quot;Your balance is $&quot; + (0.1 + 0.2)</pre><p>You’ll get the title of this article.</p><p>Because, by definition, <a href="https://husobee.github.io/money/float/2016/09/23/never-use-floats-for-currency.html">we cannot have</a> an exact representation of 0.1 or any negative power of ten in binary, we cannot use floats to accurately store and operate on money values without also having to use rounding.</p><p>The simplest way to completely avoid this issue is to use another data type than floats for representing monetary amounts. A frequent solution is to use integers, representing a money amount in its smallest unit (for example, 100 cents for USD instead of 1.00 USD). Decimal data types also work well, granted that your language supports them (java has BigDecimal, javascript doesn’t have any).</p><h4>Allocation</h4><p>The second most-encountered arithmetical problem probably is the use of division &amp; rounding instead of allocation. Take this example: your ride-hailing app has a small reservation fee of $0.99 that you equally split between you and the driver. Should you use division and rounding,</p><pre>= round(0.99 / 2) + round(0.99 /2)<br>= round(0.495) + round(0.495)<br>= 0.5 + 0.5<br>= 1</pre><p>Assuming that your rounding function rounds to the nearest integer half up, a common default , an extra cent will be introduced to the system as $0.99 becomes $1. Rinse and repeat this operation on each ride and your system will quickly be completely off.</p><p>For this problem to be solved, rounding needs to be completely taken off the table and an actual decision needs to replace it: will the driver of the platform get the unsplittable cent?</p><p>👉 This solution is simply called allocation, and <a href="https://sarahdayan.github.io/dinero.js/module-Dinero.html#~allocate">is often implemented</a> by money manipulating libraries.</p><h3>Concurrency issues</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DEkUQNBlVWTTw4GLaHKDvw.png" /><figcaption>Young programmer discovering the power of race conditions</figcaption></figure><p>Back in 2015, a security researcher <a href="http://sakurity.com/blog/2015/05/21/starbucks.html">found a way</a> to create unlimited money on Starbucks gift cards exploiting what is know as a race condition. Far from being a one-off, this kind of bug is a habitual offender of homebrew financial systems.</p><p>A race condition happen anytime code that wasn’t designed to run concurrently does so. The textbook example of this would be a wallet API that lets you draw more money from a wallet than available, on the condition that multiple withdrawal calls are executed at the same time.</p><p>To test your API against this issue, you need nothing more than curl with seq and xargs. Here’s an example:</p><pre>#!/bin/bash</pre><pre>seq 1 10 | \<br>xargs -n1 -P3 \<br>curl <a href="http://localhost/api/withdraw">http://localhost/api/withdraw</a> \<br>-X POST \<br>-H &#39;Content-Type: application/json&#39; \<br>-d &#39;{&quot;from&quot;: &quot;1234&quot;, &quot;amount&quot;: 100}&#39;</pre><p>With this simple bash script, we’ll have 10 calls to our endpoint with a maximum of 3 jobs running in parallel. Is this test manages to go beyond what should be possible on your API, you have a race-condition.</p><p>The good news is — for most cases — this problem can be easily solved by locking. By using a mutex lock and serializing the calls processing, you make sure that your condition that checks wether the balance is sufficient or not will not be jeopardized by another thread. Unfortunately, there are cases where introducing a lock might not be that easy as <a href="https://en.wikipedia.org/wiki/Lock_(computer_science)#Granularity">their complexity</a> will start to leak and tradeoffs will have to be made. These cases can include applications with high throughput or reduced access to network, all of which go beyond the scope of this article.</p><h3>Unhandled remote failures</h3><h4>Null values</h4><p>When a remote service fails to provide a value used further down in your system, you can either halt the system or use a previously obtained value if possible. What should not be done is to save a buggy value and continue operations as if nothing happened.</p><p>An example of this is currency conversion. Should a conversion rate fail to be fetched from a remote web-service, the last thing to do would be to save <em>null</em> and subsequently use this <em>null</em> rate to compute prices. If you were an airline company, flights tickets could be <a href="https://news.ycombinator.com/item?id=22278325">purchased</a> for $0 thanks to this bug.</p><h4>Partial processing</h4><p>Another kind of unhandled remote failure emerges from partial processing. Say you initiate a transfer on your bank API, and the TCP connection dies in the middle of it. If you retry the call, you will risk executing the transfer twice. depending on wether the bank had received the request or not.</p><p>👉 One solution to this problem would be checking if the transfer happened before retrying it. While not universal, another simpler solution is the use of <a href="https://stripe.com/docs/api/idempotent_requests">idempotency keys</a>, granted the API you’re calling implements them.</p><h3>Silent failures</h3><h4>Missed captures</h4><p>Sometimes, the worst stories are not about how something terrible happened but rather how something critical dit <strong><em>not</em></strong> happen. In financial software, things that do not happen can sometimes result in pure money loss. An example of this is the <a href="https://en.wikipedia.org/wiki/Authorization_hold">authorize and capture</a> workflow found on the API of most card payment service providers. When your code fails to capture an authorization and still proceeds with the sale, the money is lost forever.</p><p>👉 There is no off-the-shelf solution to this problem, as the solution largely depends on the specifics of your system. A decent approach we recommend sources its inspiration in contract programming and is to have a side system to continuously verify that what your main system did holds up to your expectations. We will soon publish an article on the <em>Audit Layer</em> we built at Selency, which implements this pattern and covers this case for us.</p><h3>What now?</h3><p>Building correct software is hard. Building correct financial software is critical. This inventory, this bestiary of gold-eating monsters of sorts, was built with the hope that it will help you check your current system and avoid preventable catastrophes.</p><p>All of these issues were either issues we experienced firsthand while building the Selency marketplace, or faced by members of our community : special thanks to AssoConnect, Yescapa and Meet in Class for sharing their valuable insights on the matter.</p><p>If you have stories yourself or think about other kind of failures, please share them in the comments — I’ll be thrilled to add new monsters to the bestiary.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6f7870bd32e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/selency-tech-product/your-balance-is-0-30000000004-b6f7870bd32e">Your balance is $0.30000000004</a> was originally published in <a href="https://medium.com/selency-tech-product">Selency Tech &amp; Product</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating to Stripe Connect]]></title>
            <link>https://medium.com/selency-tech-product/migrating-to-stripe-connect-3764f8bccfba?source=rss-eed605d08e6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3764f8bccfba</guid>
            <category><![CDATA[stripe]]></category>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[marketplaces]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[fintech]]></category>
            <dc:creator><![CDATA[Clément Salaün]]></dc:creator>
            <pubDate>Tue, 02 Jul 2019 08:41:33 GMT</pubDate>
            <atom:updated>2019-07-02T08:41:33.074Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to design &amp; deliver a big-impact, risk-free PSP migration</h4><p>With PSD2 being pushed downstream from European parliament to countries implementations and new requirements coming into play, we decided it was time for us to choose a new payment partner.</p><p>As a marketplace, changing your main payment processor is no small feat; this article reflects the strategy we used at Selency to deliver that big switch.</p><h3>The case for Stripe Connect</h3><h4>Flexibility</h4><p>Marketplaces face complex payment flows. The mantra is to always stay as close to 1:1 as possible: money should get out the same way it got in, and you should delegate as much as possible to your processor. This however is not always easy, due to corner cases well known to marketplaces (e.g. 100€ comes in but 200€ are redistributed to the merchants, because the customer paid using a coupon you sponsor).</p><p>Stripe’s <a href="https://stripe.com/docs/connect/charges-transfers">Separate Charges and Transfers</a> solution occupies a nice spot in the flexibility / compliance spectrum, providing an API that lets you handle the money-splitting logic while still remaining fully PSD2 compliant.</p><h4>Reliability</h4><p>The multiplicity of actors, integration challenges, and legislation evolutions make for a complex payment ecosystem. Failures are common, and vendors offer varying levels of shielding from these failures. Our previous partner, in addition to providing little shielding, added their own extra layer of failures. Accountability was also an issue, as it was our responsibility to provide logs when things went haywire on their side.</p><p>Reliability is especially important as you scale, as any time spent on manual repairs will grow non-linearly following your company growth function and rapidly become unmanageable.</p><p>Stripe’s reliability is demonstrated in various ways, from their status page to their precious in-dashboard API requests logs.</p><h3>Establishing the migration framework</h3><p>The last thing you want is to find yourself pushing a big red button and suddenly have all your transactions processed by your new processor. By establishing a clear migration framework, we can focus on the objectives we want to maximize, namely:</p><h4>☑️ Safety</h4><p>This one is a given. At any moment in time, should you be in control of the migration, i.e. have the ability to monitor, rollout and rollback.</p><h4>☑️ User Experience</h4><p>Ultimately your users, especially your merchants, will be the one experiencing the migration. It should not come as a surprise-surprise-emergency to them and be the lesser of a burden as possible.</p><h4>☑️ Room for learning</h4><p>While general concepts can be grasped from documentation and sandboxes, it takes time and real-world transactions to learn all the intricacies of any new solution.</p><p>In addition to these objectives, we identify sanity metrics that will be followed during and after the migration:</p><h4>📊 Conversion</h4><p>Conversion is the easiest metric to monitor and speaks for itself: this one shouldn’t drop on cash-in made with the new system.</p><h4>📊 Adoption</h4><p>How many merchants have completed the migration process and are ready for Stripe cash-out?</p><h4>📊 Time to cash-out</h4><p>We measure time to cash-out as the delay in days between the payout request for a sale by a merchant and the actual processing of the payout. Averaging it provides a simple and efficient proxy to the cash-out pipeline health.</p><p>With these objectives and metrics in mind, we can start to design our migration plan.</p><h3>Sequencing</h3><p>The first step to establishing your plan is to lay out its sequencing, relative to cash-in and cash-out releases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9MklPTfD06SrxERNpEVlLw.png" /><figcaption>The five stages of our migration</figcaption></figure><p>We choosed to order the stages as-is to fight the hardest battle first: migrating the cash-out. Before starting to issue transfers with Stripe, you will need to onboard your existing merchants base which, as <a href="https://stripe.com/docs/connect/account-tokens">Account Tokens</a> are either recommended or mandatory depending on your country, <strong>will require an in-browser action on their side</strong> (more on that below in Selling the switch)<strong>.</strong></p><h3>Handling overlaps</h3><p>Once the sequencing is laid out, it is easy to identify overlaps in cash-in and cash-out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-4aE6Hur72RVtUFHPlu5kQ.png" /></figure><p>Overlaps induce their own funds management problems. How can funds cashed in with legacy PSP be cashed out with Stripe?</p><p>To solve this issue, we introduced to our order system an audit layer with funds management capabilities. The audit layer in itself could be the main subject of another article. For the sake of this migration, its role was to continuously keep in check inputs and outputs: if the output gateway didn’t match the input gateway, the system would take note of the required funds movements to make to reach equilibrium.</p><p>It is especially important to involve Stripe while designing your overlaps and funds movements strategy so they can greenlight it.</p><p>Migration plans without overlaps are possible, but overlaps allow for a safe and progressive rollout of the new cash-in and cash-out. Without designed overlaps management, you’ll be resorting to a big-bang with no AZ-5.</p><h3>Segmentation</h3><p>Once the sequencing is clear, it is time to bucket your users to allow for a progressive rollout. The strategies we used were different for cash-in and cash-out.</p><p>For cash-out, we bucketed our merchants according to their current state of account usability: priority was given to merchants failing to get their account validated on our legacy PSP, which helped us to confirm our integration was working well on our most complex cases as well as give them the chance to solve their validation problems faster.</p><p>For cash-in, a simple roll-out by 10% increments of our user base was put in place.</p><h3>Selling the switch</h3><p>I’m no wiz but can assure you no one wants to wake up one day and have to fill an identity &amp; payment details form over the Internet. That’s precisely why we invested time designing a migration process as frictionless as possible for our merchants.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M-5KlkE55_h1fk9CnQuVSQ.png" /><figcaption>Hello we need ur ID again</figcaption></figure><p>We used a popin for the migration form, as it could be displayed on any page, triggered by sellers actions related to their orders and payments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aS_WxwX8ge6A28E7b8sYCw.png" /></figure><p>The popin itself was structured as above, with the hard work (personal info steps) prefaced by a marketing pitch. We also used the migration as an opportunity to implement a very-much-awaited “Automatic Payout Requests” merchant feature, which further helped the pitch.</p><p>As Stripe’s account tokens system let you the opportunity to collect the user data in your own forms, we were able to pre-fill the personal info steps as much as possible.</p><h3>Final thoughts</h3><p>The time required to complete a migration to Stripe Connect is largely dependent on your company unique characteristics and current state of payments infrastructure. You will possibly end-up with another sequencing, another segmentation, alternative metrics to monitor.</p><p>What’s most important is to spend time designing your migration framework. The structure we recommend is the one described in this article:</p><p><strong><em>Objectives + Metrics </em></strong>➡️ <strong><em>Sequencing + Overlaps </em>➡️<em> Segmentation + Rollout</em></strong></p><p>At Selency — a pretty complex marketplace with thousands of sellers — we were able to complete the cash-out migration in a solid month, with one developer working on it full-time and another as an active reviewer. Implementing the cash-in took another two short weeks, most of the work lying in the progressive rollout part.</p><p><em>We’d also like to use this article as an opportunity to thank Stripe’s team: shoutout to Pierre, Carlo and Martin for their help and engagement in making this migration a success.</em></p><p>PS: We are looking for <a href="https://www.welcometothejungle.co/fr/companies/selency">talents</a> ;-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3764f8bccfba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/selency-tech-product/migrating-to-stripe-connect-3764f8bccfba">Migrating to Stripe Connect</a> was originally published in <a href="https://medium.com/selency-tech-product">Selency Tech &amp; Product</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>