<?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 Isindu Tharudinitha on Medium]]></title>
        <description><![CDATA[Stories by Isindu Tharudinitha on Medium]]></description>
        <link>https://medium.com/@tharudinitha?source=rss-1907b4e051d9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ilkse1mg7sGjExBujc_MpA.jpeg</url>
            <title>Stories by Isindu Tharudinitha on Medium</title>
            <link>https://medium.com/@tharudinitha?source=rss-1907b4e051d9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 04:15:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tharudinitha/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[Docker Agents vs VMs in Azure DevOps Pipelines: A Complete Guide to CI/CD Job Execution]]></title>
            <link>https://medium.com/@tharudinitha/docker-agents-vs-vms-in-azure-devops-pipelines-a-complete-guide-to-ci-cd-job-execution-84c6d401fee9?source=rss-1907b4e051d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/84c6d401fee9</guid>
            <category><![CDATA[virtual-machine]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Isindu Tharudinitha]]></dc:creator>
            <pubDate>Sat, 01 Aug 2026 18:23:06 GMT</pubDate>
            <atom:updated>2026-08-01T18:23:06.897Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/980/0*rYLZD0Lv9VJrYOvH.jpg" /></figure><h3>Introduction</h3><p>If you’ve been exploring Azure DevOps CI/CD pipelines, you’ve likely encountered two different approaches to running pipeline jobs:</p><ol><li><strong>Direct execution on a VM</strong> (Virtual Machine)</li><li><strong>Execution inside Docker containers</strong> (Container Jobs)</li></ol><p>The confusion is understandable. Both approaches work. Both are widely used. But they solve different problems and come with different trade-offs.</p><p>In this article, I’ll explain what’s actually happening under the hood, why companies choose one approach over the other, and provide practical examples you can use in your own pipelines.</p><h3>The Three Ways to Run Pipeline Jobs</h3><p>Before we dive into Docker vs VMs, let’s understand the complete picture. Azure DevOps actually supports three different execution models:</p><h3>Option 1: Microsoft-Hosted VMs (Most Common)</h3><pre>Azure DevOps → Microsoft-Hosted Ubuntu VM → Pipeline Steps Execute Here</pre><p>You specify a pool with a Microsoft-managed image:</p><pre>pool:<br>  vmImage: &#39;ubuntu-latest&#39;</pre><p>What happens:</p><ul><li>Azure DevOps provisions a temporary Ubuntu VM</li><li>Your entire pipeline runs directly on this VM</li><li>The VM already has common tools pre-installed (Docker, Node, Git, Azure CLI, etc.)</li><li>The VM is destroyed after your pipeline completes</li></ul><p><strong>Example:</strong></p><pre>pool:<br>  vmImage: &#39;ubuntu-latest&#39;</pre><pre>steps:<br>- task: NodeTool@0<br>  inputs:<br>    versionSpec: &#39;18.x&#39;<br>  displayName: &#39;Install Node.js&#39;</pre><pre>- script: |<br>    npm ci<br>    npm run build<br>  displayName: &#39;Install dependencies and build React app&#39;</pre><p>Here, npm ci and npm run build run directly on the Ubuntu VM&#39;s operating system.</p><h3>Option 2: Self-Hosted VMs (You Manage)</h3><pre>Azure DevOps → Your Azure VM → Pipeline Steps Execute Here</pre><p>You configure a self-hosted agent:</p><pre>pool:<br>  name: &#39;My-Self-Hosted-Agents&#39;</pre><p>What happens:</p><ul><li>You maintain your own VM(s)</li><li>You install the Azure DevOps agent software on it</li><li>The agent registers with Azure DevOps</li><li>Your pipeline runs on your infrastructure</li></ul><p><strong>When to use this:</strong></p><ul><li>You need persistent state between runs</li><li>You have specialized hardware requirements</li><li>You want to minimize per-run overhead</li><li>You need to use private networks without internet exposure</li></ul><h3>Option 3: Container Jobs (The Modern Approach)</h3><pre>Azure DevOps → VM (Microsoft-hosted or self-hosted) → Docker → Container → Pipeline Steps Execute Here</pre><p>You add a container: specification:</p><pre>pool:<br>  vmImage: &#39;ubuntu-latest&#39;</pre><pre>container: node:18</pre><pre>steps:<br>- script: npm ci<br>- script: npm run build</pre><p>What happens:</p><ul><li>Azure DevOps provisions a VM (same as Option 1)</li><li>Docker Engine pulls your specified container image</li><li>Every pipeline step runs <strong>inside that container</strong>, not on the host VM</li><li>The container is removed when the pipeline completes</li></ul><p>This is the <strong>critical point many people miss</strong>: <em>the VM still exists</em>. The container doesn’t replace the VM — it runs on top of it.</p><h3>The Architecture Difference: Visualized</h3><h3>Direct VM Execution</h3><pre>┌─────────────────────────────────┐<br>│      Azure DevOps Platform      │<br>└────────────────┬────────────────┘<br>                 │<br>                 ▼<br>┌─────────────────────────────────┐<br>│      Ubuntu VM (vmImage)        │<br>│  ┌──────────────────────────────┤<br>│  │ - Node 18.x                  │<br>│  │ - npm 9.x                    │<br>│  │ - Docker                     │<br>│  │ - Java                       │<br>│  │ - .NET                       │<br>│  │ - Azure CLI                  │<br>│  └──────────────────────────────┤<br>└─────────────────────────────────┘<br>         │<br>         ▼<br>┌─────────────────────────────────┐<br>│    npm ci &amp;&amp; npm run build      │<br>│ (Runs directly on Ubuntu)       │<br>└─────────────────────────────────┘</pre><p><strong>Everything happens on the host VM’s operating system.</strong></p><h3>Container Job Execution</h3><pre>┌─────────────────────────────────┐<br>│      Azure DevOps Platform      │<br>└────────────────┬────────────────┘<br>                 │<br>                 ▼<br>┌─────────────────────────────────┐<br>│      Ubuntu VM (vmImage)        │<br>│  ┌──────────────────────────────┤<br>│  │    Docker Engine             │<br>│  │    ┌────────────────────────┐│<br>│  │    │  Node 18 Container     ││<br>│  │    │  ┌────────────────────┐││<br>│  │    │  │ Isolated Filesystem││<br>│  │    │  │ npm 10              ││<br>│  │    │  │ Specific Libraries  ││<br>│  │    │  │ node_modules        ││<br>│  │    │  └────────────────────┘││<br>│  │    └────────────────────────┘│<br>│  └──────────────────────────────┤<br>└─────────────────────────────────┘<br>         │<br>         ▼<br>┌─────────────────────────────────┐<br>│    npm ci &amp;&amp; npm run build      │<br>│  (Runs inside the container)    │<br>└─────────────────────────────────┘</pre><p><strong>Everything happens inside an isolated container with its own filesystem, libraries, and dependencies.</strong></p><h3>Why Use Docker Containers? The Real Problem</h3><p>Let me illustrate with a real-world scenario.</p><h3>The Problem: Build Drift</h3><p><strong>Today</strong>, Microsoft’s hosted VM image includes:</p><ul><li>Node 18.x</li><li>npm 9.x</li><li>Python 3.12</li><li>OpenSSL 3.0</li></ul><p>Your pipeline runs successfully. Everything works.</p><p><strong>Next month</strong>, Microsoft updates the hosted image:</p><ul><li>Node 20.x</li><li>npm 11.x</li><li>Python 3.13</li><li>OpenSSL 3.2</li></ul><p>Your build suddenly breaks because:</p><ul><li>A npm package requires an older version</li><li>Python 3.13 has breaking changes</li><li>OpenSSL 3.2 deprecated something you use</li></ul><p><strong>This is called “build drift”</strong> — your build environment changes without your consent.</p><p>With container jobs, you control the exact environment:</p><pre>FROM node:18.20.0</pre><pre>RUN apt-get update &amp;&amp; apt-get install -y \<br>    python3.11 \<br>    openssl-1.1 \<br>    # other specific versions</pre><pre>RUN npm install -g npm@10.2.0</pre><p>Now your pipeline always uses exactly these versions — <strong>no surprises, no drift</strong>.</p><h3>Advantages &amp; Disadvantages: The Trade-Off Matrix</h3><h3>VM Jobs (Direct Execution)</h3><p><strong>Advantages:</strong> ✅ Simple to set up — just specify vmImage<br> ✅ No Docker knowledge required<br> ✅ Quick to get started<br> ✅ Good for small, self-contained projects<br> ✅ Pre-installed tools available immediately<br> ✅ Lower cognitive overhead</p><p><strong>Disadvantages:</strong> ❌ Depends entirely on Microsoft’s image maintenance schedule<br> ❌ Tool versions can change unexpectedly<br> ❌ Different developers may have different versions locally<br> ❌ Hard to replicate the CI environment on a local machine<br> ❌ Scaling across teams means everyone uses Microsoft’s version choices</p><p><strong>Best for:</strong></p><ul><li>Small projects</li><li>Quick prototypes</li><li>Projects with stable, widely-available dependencies</li><li>Teams new to CI/CD</li></ul><h3>Container Jobs (Docker-Based Execution)</h3><p><strong>Advantages:</strong> ✅ <strong>Full control over the build environment</strong><br> ✅ <strong>Reproducible builds</strong> — same container locally and in CI<br> ✅ <strong>Teams stay in sync</strong> — all developers use the exact same environment<br> ✅ <strong>Predictable</strong> — no surprise updates<br> ✅ <strong>Easy to pin versions</strong> — Node 18.20.0, not just 18.x<br> ✅ <strong>Great for complex applications</strong> — custom dependencies baked in<br> ✅ <strong>Security</strong> — teams can approve a specific set of tools</p><p><strong>Disadvantages:</strong> ❌ More complex to set up initially<br> ❌ You must build and maintain the container image<br> ❌ Requires understanding of Docker<br> ❌ Slight startup overhead (pulling the image)<br> ❌ Image size affects pull speed<br> ❌ More files to manage (Dockerfile, image registry)</p><p><strong>Best for:</strong></p><ul><li>Larger teams and organizations</li><li>Projects with specific version requirements</li><li>Teams using multiple programming languages</li><li>High-stakes projects where reproducibility matters</li><li>Microservices architectures</li></ul><h3>Real Pipeline Examples</h3><p>Now let’s look at concrete examples. I’ll show you both approaches using a React application.</p><h3>Example 1: VM Job (Direct Execution)</h3><p>Here’s a pipeline that runs directly on Microsoft’s hosted Ubuntu VM:</p><pre># azure-pipelines.yml (VM Approach)<br>trigger:<br>  branches:<br>    include:<br>      - master<br>      - main</pre><pre>variables:<br>  dockerRegistryServiceConnection: &#39;Container-Registry&#39;<br>  imageRepository: &#39;my-react-app&#39;<br>  containerRegistry: &#39;$(ACR_NAME).azurecr.io&#39;<br>  tag: &#39;$(Build.BuildId)&#39;</pre><pre>stages:<br>  - stage: Build<br>    displayName: &#39;Build Stage&#39;<br>    jobs:<br>      - job: BuildJob<br>        displayName: &#39;Build Docker Image&#39;<br>        <br>        # This is the key: we use Microsoft-hosted VM<br>        pool:<br>          vmImage: &#39;ubuntu-latest&#39;<br>        <br>        steps:<br>          # Step 1: Checkout code<br>          - checkout: self<br>            fetchDepth: 1<br>          <br>          # Step 2: Install Node.js (using whatever version is on the VM)<br>          - task: NodeTool@0<br>            inputs:<br>              versionSpec: &#39;18.x&#39;<br>            displayName: &#39;Install Node.js&#39;<br>          <br>          # Step 3: Build React app directly on the VM<br>          - script: |<br>              echo &quot;Building React app on Ubuntu VM...&quot;<br>              npm ci<br>              npm run build<br>            displayName: &#39;Build React Application&#39;<br>          <br>          # Step 4: Docker build (using VM&#39;s Docker)<br>          - task: Docker@2<br>            displayName: &#39;Build Docker Image&#39;<br>            inputs:<br>              containerRegistry: &#39;$(dockerRegistryServiceConnection)&#39;<br>              repository: &#39;$(imageRepository)&#39;<br>              command: &#39;build&#39;<br>              Dockerfile: &#39;$(Build.SourcesDirectory)/Dockerfile&#39;<br>              tags: |<br>                $(tag)<br>                latest<br>          <br>          # Step 5: Push to registry<br>          - task: Docker@2<br>            displayName: &#39;Push to ACR&#39;<br>            inputs:<br>              containerRegistry: &#39;$(dockerRegistryServiceConnection)&#39;<br>              repository: &#39;$(imageRepository)&#39;<br>              command: &#39;push&#39;<br>              tags: |<br>                $(tag)<br>                latest</pre><pre>    # Deploy stage would go here</pre><p><strong>What’s happening:</strong></p><ul><li>npm ci and npm run build run directly on Ubuntu</li><li>Whatever Node version is pre-installed is used</li><li>Docker is available because the VM has it</li><li>Simple, straightforward, works immediately</li></ul><p><strong>The problem:</strong> If Microsoft updates the VM image and introduces a breaking change, your build breaks automatically on the next run.</p><h3>Example 2: Container Job (Docker-Based Execution)</h3><p>Now here’s the same pipeline using a container job:</p><pre># azure-pipelines.yml (Container Approach)<br>trigger:<br>  branches:<br>    include:<br>      - master<br>      - main</pre><pre>variables:<br>  dockerRegistryServiceConnection: &#39;Container-Registry&#39;<br>  imageRepository: &#39;my-react-app&#39;<br>  containerRegistry: &#39;$(ACR_NAME).azurecr.io&#39;<br>  tag: &#39;$(Build.BuildId)&#39;<br>  buildImageRegistry: &#39;$(containerRegistry)&#39;<br>  buildImage: &#39;build-base:1.0&#39;</pre><pre>stages:<br>  - stage: Build<br>    displayName: &#39;Build Stage&#39;<br>    jobs:<br>      - job: BuildJob<br>        displayName: &#39;Build Docker Image&#39;<br>        <br>        pool:<br>          vmImage: &#39;ubuntu-latest&#39;<br>        <br>        # THIS IS THE KEY ADDITION: We specify a container<br>        container:<br>          image: &#39;$(buildImageRegistry)/$(buildImage)&#39;<br>          endpoint: &#39;$(dockerRegistryServiceConnection)&#39;<br>        <br>        steps:<br>          # Step 1: Checkout code<br>          - checkout: self<br>            fetchDepth: 1<br>          <br>          # Step 2: No need to install Node - it&#39;s already in the container<br>          - script: |<br>              echo &quot;Node version:&quot;<br>              node --version<br>              echo &quot;npm version:&quot;<br>              npm --version<br>            displayName: &#39;Verify Node.js in Container&#39;<br>          <br>          # Step 3: Build React app inside the container<br>          - script: |<br>              echo &quot;Building React app inside container...&quot;<br>              npm ci<br>              npm run build<br>            displayName: &#39;Build React Application&#39;<br>          <br>          # Step 4: Docker build (using host VM&#39;s Docker)<br>          - task: Docker@2<br>            displayName: &#39;Build Docker Image&#39;<br>            inputs:<br>              containerRegistry: &#39;$(dockerRegistryServiceConnection)&#39;<br>              repository: &#39;$(imageRepository)&#39;<br>              command: &#39;build&#39;<br>              Dockerfile: &#39;$(Build.SourcesDirectory)/Dockerfile&#39;<br>              tags: |<br>                $(tag)<br>                latest<br>          <br>          # Step 5: Push to registry<br>          - task: Docker@2<br>            displayName: &#39;Push to ACR&#39;<br>            inputs:<br>              containerRegistry: &#39;$(dockerRegistryServiceConnection)&#39;<br>              repository: &#39;$(imageRepository)&#39;<br>              command: &#39;push&#39;<br>              tags: |<br>                $(tag)<br>                latest</pre><p><strong>What’s happening:</strong></p><ul><li>The build container is pulled first</li><li>npm ci and npm run build run <strong>inside that container</strong></li><li>The container has exact versions you specified</li><li>Microsoft’s hosted VM still exists (to run Docker and orchestrate), but your actual work happens in the container</li></ul><h3>The Build Container Dockerfile</h3><p>For this to work, you need to create and push a build container:</p><pre># Dockerfile.build<br>FROM node:18.20.0</pre><pre># Install exact versions you need<br>RUN apt-get update &amp;&amp; apt-get install -y \<br>    python3.11 \<br>    openssl \<br>    curl \<br>    git</pre><pre># Install exact npm version<br>RUN npm install -g npm@10.2.0</pre><pre># Set working directory<br>WORKDIR /app</pre><pre># Verify versions<br>RUN node --version &amp;&amp; npm --version &amp;&amp; python3 --version</pre><pre># This container is ready for your builds</pre><p>Then build and push it:</p><pre># Build locally to test<br>docker build -f Dockerfile.build -t my-build-base:1.0 .</pre><pre># Tag and push to ACR<br>docker tag my-build-base:1.0 myacr.azurecr.io/build-base:1.0<br>docker push myacr.azurecr.io/build-base:1.0</pre><p>Now your pipeline references this image:</p><pre>container:<br>  image: &#39;myacr.azurecr.io/build-base:1.0&#39;</pre><h3>How to Choose: Decision Tree</h3><p>Ask these questions:</p><h3>1. How many developers and projects?</h3><ul><li><strong>Small team, few projects</strong>: VM jobs probably fine</li><li><strong>Large team, many projects</strong>: Container jobs ensure consistency</li></ul><h3>2. Are you concerned about build drift?</h3><ul><li><strong>“We never have problems”</strong>: VM jobs work</li><li><strong>“We had to fix builds last month”</strong>: Container jobs are your answer</li></ul><h3>3. Do you have complex dependencies?</h3><ul><li><strong>Simple (just Node)</strong>: VM jobs suffice</li><li><strong>Complex (Node + Python + Java + custom libs)</strong>: Container jobs excel</li></ul><h3>4. Do your developers need to reproduce builds locally?</h3><ul><li><strong>No, just trust CI</strong>: VM jobs work</li><li><strong>Yes, developers must have identical setup</strong>: Container jobs required</li></ul><h3>5. How long until you outgrow this?</h3><ul><li><strong>“We’re a startup, keep it simple”</strong>: VM jobs</li><li><strong>“We’re scaling, we need predictability”</strong>: Container jobs</li></ul><h3>Migration Path: VM → Container</h3><p>If you’re currently using VM jobs and want to migrate to container jobs:</p><p><strong>Step 1: Create a Dockerfile.build</strong></p><pre>FROM node:18.20.0<br>RUN apt-get update &amp;&amp; apt-get install -y python3 curl git<br>RUN npm install -g npm@10.2.0<br>WORKDIR /app</pre><p><strong>Step 2: Test locally</strong></p><pre>docker build -f Dockerfile.build -t my-build-base:1.0 .<br>docker run -it my-build-base:1.0 /bin/bash<br># Inside container, verify: node --version, npm --version, etc.</pre><p><strong>Step 3: Push to container registry</strong></p><pre>docker tag my-build-base:1.0 myacr.azurecr.io/build-base:1.0<br>docker push myacr.azurecr.io/build-base:1.0</pre><p><strong>Step 4: Update your pipeline</strong></p><pre>pool:<br>  vmImage: &#39;ubuntu-latest&#39;</pre><pre>container:<br>  image: &#39;myacr.azurecr.io/build-base:1.0&#39;<br>  endpoint: &#39;Isindu-Container-Registry&#39;</pre><pre>steps:<br>  # Your existing steps work without modification</pre><p><strong>Step 5: Test and iterate</strong> Run your pipeline and verify it still works. If something breaks, it’s now in the container, not the VM.</p><h3>Common Misconception: “Docker Agent” Terminology</h3><p>When you hear <strong>“Docker agent,”</strong> it could mean two different things:</p><h3>Meaning 1: Container Jobs (What We Discussed)</h3><p>Pipeline steps run inside a Docker container. The container is temporary, created per pipeline run.</p><h3>Meaning 2: Self-Hosted Agent in Docker</h3><p>The Azure DevOps agent software itself runs in a Docker container on a persistent server. The agent is long-lived and registers with Azure DevOps.</p><pre># This creates a self-hosted agent inside Docker<br>docker run -it \<br>  -e AZP_URL=https://dev.azure.com/yourorg \<br>  -e AZP_TOKEN=yourtoken \<br>  -e AZP_AGENT_NAME=DockerAgent \<br>  mcr.microsoft.com/azure-pipelines/vsts-agent:ubuntu-22.04</pre><p>These are related but different concepts. <strong>Container jobs</strong> (Option 3) are about running pipeline steps in a temporary container. <strong>Self-hosted agents in Docker</strong> are about the agent infrastructure itself.</p><h3>Conclusion: Pick Based on Your Reality</h3><p><strong>Use VM jobs if:</strong></p><ul><li>You’re just getting started with CI/CD</li><li>Your project has simple, stable dependencies</li><li>You have a small team</li><li>You trust Microsoft’s maintenance schedule</li></ul><p><strong>Use Container jobs if:</strong></p><ul><li>You want reproducible builds</li><li>You have complex dependencies</li><li>You’re scaling across teams</li><li>You need to pin exact tool versions</li><li>You want developers and CI to be identical</li></ul><p>Both are valid. Neither is “better” — they solve different problems.</p><p>The key insight: <strong>container jobs don’t remove the VM, they add a layer of control on top of it</strong>. You get consistency without sacrificing the speed and simplicity of Microsoft-hosted infrastructure.</p><h3>Next Steps</h3><ol><li><strong>Decide</strong>: Does your project need reproducibility or simplicity?</li><li><strong>Create a Dockerfile</strong>: If choosing containers, build one tailored to your dependencies</li><li><strong>Test locally</strong>: Run docker run -it yourimage /bin/bash and verify your tools work</li><li><strong>Update your pipeline</strong>: Add the container: specification</li><li><strong>Monitor</strong>: Run a few builds and verify everything works as expected</li></ol><p>The investment in container jobs pays dividends as your project and team grow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84c6d401fee9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A developer’s honest account of building production-grade API monetization, and why Stripe’s…]]></title>
            <link>https://medium.com/@tharudinitha/a-developers-honest-account-of-building-production-grade-api-monetization-and-why-stripe-s-5a2a6094bf78?source=rss-1907b4e051d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a2a6094bf78</guid>
            <category><![CDATA[api-monetization]]></category>
            <category><![CDATA[wso2-apim]]></category>
            <category><![CDATA[stripe]]></category>
            <category><![CDATA[wso2]]></category>
            <dc:creator><![CDATA[Isindu Tharudinitha]]></dc:creator>
            <pubDate>Mon, 20 Apr 2026 11:02:31 GMT</pubDate>
            <atom:updated>2026-04-20T11:02:31.295Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/247/1*-wgS6XqpFvT96qqpVSqR0g.png" /></figure><h3>Integrating Stripe with WSO2 API Manager 4.5.0 — What They Don’t Tell You in the Docs</h3><p><strong>A developer’s honest account of building production-grade API monetization, and why Stripe’s sandbox environment made all the difference</strong></p><p>I spent the better part of several weeks configuring Stripe-based API monetization on WSO2 API Manager 4.5.0. The official documentation makes it look straightforward. It is not. But somewhere in the middle of all the stack traces, database queries, and Java source code fixes, I discovered something that genuinely impressed me: Stripe’s developer tooling is so good that by the time I was ready to go live, I had already simulated months of real billing cycles, tested every failure scenario imaginable, and fixed every edge case — all without touching a single real credit card.</p><p>This article is about that journey. The architecture decisions, the things that broke, the custom workflow we built, and most importantly, what Stripe’s sandbox environment gives you as a developer that most billing providers simply do not.</p><h3>What We Were Building</h3><p>The goal was straightforward on paper: allow API publishers on WSO2 API Manager to attach a monthly price to their APIs, and have subscribers automatically billed through Stripe when they subscribe. Renewals should be automatic. Invoices should generate themselves. The admin should be able to require approval before a monetized API subscription is activated.</p><p>The reality of building this involved three interconnected systems — WSO2 APIM 4.5.0, a custom Java plugin JAR, and Stripe’s Connect platform — none of which talk to each other out of the box without careful wiring.</p><h3>Understanding the Architecture First</h3><p>Before anything compiles or deploys, you need to understand the three-actor model that makes this work. Getting this wrong at the start costs you days of confusion later.</p><p><strong>The Tenant Admin</strong> is the platform owner. They hold the main Stripe account and the platform secret key (sk_test_...). This key goes into WSO2&#39;s Advanced Configuration as BillingEnginePlatformAccountKey. It is the root credential that authorises all Stripe operations.</p><p><strong>The API Publisher</strong> is an individual API owner. They have their own Stripe Connected Account (acct_XXXX) linked to the platform via Stripe Connect. When they enable monetization on an API in the Publisher Portal and enter their Connected Account ID, WSO2 automatically creates a Stripe Product and a recurring Price inside their account. The subscription revenue flows directly to them.</p><p><strong>The Subscriber</strong> is the API consumer. When they subscribe via the Developer Portal, WSO2 creates a Platform Customer in the main Stripe account and a Shared Customer inside the publisher’s Connected Account. The payment method attached to the Platform Customer is automatically shared across all publisher subscriptions — subscribers add their card once and it works everywhere.</p><p>This three-layer model is Stripe Connect’s design. WSO2’s monetization plugin is built on top of it. Understanding it is the prerequisite for everything else.</p><h3>The First Thing That Broke — JAR Version Mismatch</h3><p>WSO2’s Stripe monetization plugin (org.wso2.apim.monetization.impl) is an open-source JAR available on GitHub. The version on GitHub is compiled against carbon.apimgt version 9.32.130. WSO2 API Manager 4.5.0 runs on 9.31.86. These are different enough that the JAR throws a NoSuchMethodError at runtime the moment any subscription is attempted.</p><p>The fix is to clone the plugin source, change one line in pom.xml, and rebuild:</p><p>xml</p><pre>&lt;!-- Change this: --&gt;<br>&lt;carbon.apimgt.version&gt;9.32.130&lt;/carbon.apimgt.version&gt;</pre><pre>&lt;!-- To this: --&gt;<br>&lt;carbon.apimgt.version&gt;9.31.86&lt;/carbon.apimgt.version&gt;</pre><p>But that triggers a second compilation error — getAnalyticsProtocol() does not exist in 9.31.86&#39;s MonetizationConfigurationDto. The fix there is to replace the three-line block calling that method with a single hardcoded fallback:</p><p>java</p><pre>// Replace this:<br>String protocol = config.getMonetizationConfigurationDto().getAnalyticsProtocol();<br>if (protocol == null) { protocol = HTTP_PROTOCOL; }</pre><pre>// With this:<br>String protocol = HTTP_PROTOCOL;</pre><p>Two source code changes. One rebuild. A working JAR. But you would never know any of this from reading the documentation.</p><h3>The Payment Flow — What Actually Happens</h3><p>When a subscriber clicks Subscribe in the Developer Portal, WSO2 calls Stripe’s API in the background. Here is the exact sequence:</p><ol><li>A Platform Customer is created (or reused) under the Tenant Admin’s Stripe account</li><li>A Shared Customer is cloned inside the publisher’s Connected Account</li><li>A Stripe Subscription (sub_XXXX) is created linked to the plan&#39;s Price ID</li><li>Stripe immediately generates Invoice #1</li><li>The stored card is charged — the money lands in the publisher’s account</li></ol><p>The first invoice is charged immediately with no delay. This is called subscription_create billing and Stripe intentionally skips the finalization window for it. Monthly renewals, however, follow a different path: Stripe creates the invoice in Draft status, holds it for one hour (the finalization window, during which you can programmatically adjust it), then finalizes and charges. This is why you see a one-hour gap between invoice creation and payment on renewal cycles. It is not a bug — it is an intentional design that gives platforms time to add usage charges or apply credits before billing closes.</p><h3>The Gap That Required a Custom Gateway</h3><p>WSO2’s built-in monetization assumes subscribers already have a payment method attached to their Stripe customer profile. In a real production system, subscribers need a way to enter their card details. WSO2 provides no UI for this.</p><p>The solution is a Stripe Checkout Gateway — a small Node.js middleware application that intercepts the subscribe flow, redirects the subscriber to Stripe’s hosted payment page, and creates the WSO2 subscription after payment confirmation:</p><pre>Subscriber opens subscribe link<br>        ↓<br>Gateway creates Stripe Checkout Session<br>        ↓<br>Redirect to stripe.com/checkout/...<br>        ↓<br>Subscriber enters card on Stripe&#39;s page<br>        ↓<br>Payment confirmed → /success callback<br>        ↓<br>Gateway calls WSO2 DevPortal REST API to create subscription<br>        ↓<br>Subscriber redirected to Developer Portal — subscription active</pre><p>This also means the gateway needs to handle the WSO2 OAuth token flow, which requires Dynamic Client Registration (DCR) since the default apim_devportal client is not guaranteed to exist on all deployments. The gateway auto-registers its own OAuth client on first run and caches the credentials.</p><h3>The Custom Approval Workflow</h3><p>A specific requirement on our implementation was that monetized API subscriptions should require admin approval before access is granted. WSO2 supports this natively — but enabling it applies the approval workflow to all APIs, both monetized and non-monetized. We needed it to apply selectively.</p><p>The solution was a custom WorkflowExecutor extension that checks AM_MONETIZATION at subscription time:</p><p>java</p><pre>// If the API has an entry in AM_MONETIZATION → require admin approval<br>// If not → auto-approve immediately</pre><p>The interesting technical challenge here is that WSO2’s StripeSubscriptionCreationWorkflowExecutor.execute() internally calls complete() to auto-approve. You cannot simply override execute() and return early — the subscription row in AM_SUBSCRIPTION has already been created and the Stripe billing has already fired by the time you could intercept.</p><p>The solution uses a ThreadLocal boolean flag:</p><p>java</p><pre>private static final ThreadLocal&lt;Boolean&gt; BLOCK_COMPLETE =<br>        ThreadLocal.withInitial(() -&gt; false);</pre><p>When a monetized API subscription runs:</p><ol><li>Set BLOCK_COMPLETE = true</li><li>Call super.execute() — this creates the subscription, fires Stripe billing, then tries to call complete()</li><li>The overridden complete() checks the flag — if true, it returns immediately without approving</li><li>The flag is cleared in a finally block</li><li>The subscription sits in ON_HOLD state</li><li>When the admin approves from the Admin Portal, complete() is called again — this time BLOCK_COMPLETE is false, so full approval proceeds and the status becomes UNBLOCKED</li></ol><h3>What Stripe’s Sandbox Made Possible — The Part Worth Highlighting</h3><p>All of the above was hard. But it was manageable because of how well Stripe’s sandbox environment works. Let me be specific about what this actually gave us.</p><h3>Test Cards That Simulate Real Failure Scenarios</h3><p>Stripe gives you a set of test card numbers that trigger specific behaviours. These are not just “use this to test a successful payment” — they let you simulate precise failure modes:</p><p>Card number and What it simulates</p><p>4242 4242 4242 4242Always succeeds<br>4000 0000 0000 0002Always declines — generic<br>4000 0025 0000 3155Requires 3D Secure authentication<br>4000 0000 0000 9995Insufficient funds decline<br>4100 0000 0000 0019Blocked by Stripe Radar fraud detection<br>4000 0000 0000 0069Expired card</p><p>Using these, I was able to test every subscription failure path — what happens in WSO2 when a card is declined at subscription time, what the Incomplete subscription status means, how the Incomplete_expired state is reached after 23 hours, and what the subscriber sees at each point. None of this would have been safely testable against real cards.</p><h3>Test Clocks — Simulating Months in Seconds</h3><p>This is the most powerful feature for anyone building subscription billing. A Stripe Test Clock is attached to a specific customer and lets you advance that customer’s billing timeline forward — simulating a month of real calendar time in under a second.</p><p>Without Test Clocks, validating monthly renewal behaviour would require waiting a real month between subscription creation and first renewal charge. With Test Clocks, I advanced the clock to the next billing date and immediately observed:</p><ul><li>The Draft invoice being created</li><li>The one-hour finalization window passing (shown as a timestamp gap)</li><li>The renewal charge being collected</li><li>A new Paid invoice appearing</li></ul><p>I ran this test ten times in one afternoon. That is ten months of billing simulation in a few hours.</p><h3>Webhook Testing Without a Real Event — A Tool We Explored But Have Not Fully Closed</h3><p>Stripe provides a “Send test webhook” button in the Dashboard that fires any event type directly to your configured endpoint. This is the right way to test your webhook receiver without waiting for a real payment failure — you select invoice.payment_failed, click Send, and your endpoint should receive a signed POST request immediately.</p><p>We built the webhook receiver — a Node.js endpoint at /stripe/webhook that verifies Stripe&#39;s signature header and calls the WSO2 Admin REST API to block or unblock subscriptions accordingly. The architecture is correct. However, getting events to reliably flow from Stripe through the Azure VM&#39;s network security rules into the running receiver is something we have not fully verified end-to-end yet. The Stripe Dashboard shows delivery attempts, which is where you go to confirm whether your endpoint is reachable and responding correctly.</p><p>This remains an open item on our implementation. I mention it here because the tooling Stripe provides for this — signed payloads, delivery logs, retry schedules, and the test webhook button — is genuinely well designed. The challenge in our case was on the infrastructure side, not the Stripe side.</p><h3>Sandbox and Live Are Identical</h3><p>The same code, the same API, the same behaviour. The only difference is the key prefix: sk_test_ vs sk_live_. There are no sandbox-only quirks to account for, no mock objects that behave differently from real ones, no surprises when you switch. When the sandbox works, production works.</p><p>This level of parity between test and production environments is genuinely rare. It means the confidence you build during development directly translates to confidence in production.</p><h3>Things I Would Tell Someone Starting This Tomorrow</h3><p><strong>Verify your carbon.apimgt version before doing anything else.</strong> Run ls repository/components/plugins/ | grep carbon.apimgt.impl and use that exact version in pom.xml.</p><p><strong>Understand Stripe Connect’s customer model before you write any code.</strong> Platform customers, shared customers, and connected accounts are distinct objects. A customer ID from the platform account cannot be used directly in a connected account operation. This caused several confusing errors until the mental model was clear.</p><p><strong>Build the Checkout Gateway early.</strong> The silent background charge model is fine for development but will not work for production. Building the Checkout Gateway from the start saves you from retrofitting it later.</p><p><strong>Plan for webhooks early — and do not underestimate the infrastructure side.</strong> WSO2 only knows about a subscription at creation and deletion time. Payment failures, external cancellations, and renewal events are completely invisible to WSO2 without a webhook receiver. This means a failed monthly renewal leaves a subscriber with UNBLOCKED status they should not have — a real production risk. The webhook receiver code itself is straightforward to write. What is harder is ensuring your endpoint is publicly reachable from Stripe’s servers, your network security rules allow the traffic, and your signature verification is correct. Treat this as a separate workstream from the billing logic itself, not an afterthought.</p><p><strong>Use Test Clocks for every renewal test.</strong> Do not skip them because they seem like extra setup. Fifteen minutes of Test Clock configuration saves you weeks of uncertainty about whether your renewal billing actually works.</p><h3>Final Thoughts</h3><p>WSO2 API Manager is a mature, powerful platform. Stripe is a mature, powerful payment infrastructure. Making them work together requires understanding both deeply and filling in the gaps where the integration falls short. Most of those gaps are solvable — but only if you know they exist.</p><p>The thing that made the whole journey manageable was Stripe’s commitment to developer experience. The sandbox is not an afterthought. It is a complete replica of production with extra tooling specifically designed to let you simulate and break things safely. For anyone building billing infrastructure — whether on WSO2 or any other platform — starting with Stripe means starting with the best test environment in the industry.</p><p>If you are about to start a similar implementation, I hope this saves you some of the time I spent finding these things out the hard way.</p><p><em>Isindu Tharudinitha | WSO2 API Manager 4.5.0, Stripe Connect</em></p><p><em>Tags: #APIManagement #Stripe #WSO2 #APIDevelopment #PaymentIntegration #SoftwareEngineering</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a2a6094bf78" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>