<?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 Ishara Peiris on Medium]]></title>
        <description><![CDATA[Stories by Ishara Peiris on Medium]]></description>
        <link>https://medium.com/@isharapeiris2001?source=rss-c4dfe35c7c75------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Cav38vKYnBQb7nVoPQIePg.png</url>
            <title>Stories by Ishara Peiris on Medium</title>
            <link>https://medium.com/@isharapeiris2001?source=rss-c4dfe35c7c75------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 04:34:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@isharapeiris2001/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 vs Docker Desktop: Understanding the Real Difference]]></title>
            <link>https://medium.com/@isharapeiris2001/docker-vs-docker-desktop-understanding-the-real-difference-f4841ec99b51?source=rss-c4dfe35c7c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4841ec99b51</guid>
            <category><![CDATA[docker-vs-docker-desktop]]></category>
            <dc:creator><![CDATA[Ishara Peiris]]></dc:creator>
            <pubDate>Wed, 13 May 2026 15:13:22 GMT</pubDate>
            <atom:updated>2026-05-13T15:13:22.838Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In modern software development, containerization has become a foundational concept for building scalable and portable applications. Among the most widely used tools in this space are Docker and Docker Desktop.</p><p>While these two terms are often used interchangeably, they are <strong>not the same thing</strong>. Understanding the distinction is crucial for developers, especially when transitioning from local development to production environments.</p><p>This article provides a clear, technical breakdown of Docker and Docker Desktop, their architectures, and when to use each.</p><h3>What is Docker?</h3><p>At its core, Docker is an <strong>open-source containerization platform</strong> that enables developers to package applications and their dependencies into isolated environments called <strong>containers</strong>.</p><h3>Core Components</h3><p>Docker follows a <strong>client-server architecture</strong> consisting of:</p><ul><li><strong>Docker Engine</strong> — The runtime responsible for building and running containers</li><li><strong>Docker Daemon (</strong><strong>dockerd)</strong> – A background service that manages containers, images, networks, and volumes</li><li><strong>Docker CLI (</strong><strong>docker)</strong> – A command-line interface used to communicate with the daemon via REST APIs</li></ul><h3>How It Works</h3><p>Docker leverages <strong>OS-level virtualization</strong> rather than traditional virtual machines. It uses:</p><ul><li><strong>Namespaces</strong> → for process isolation</li><li><strong>cgroups</strong> → for resource management</li><li><strong>Union file systems</strong> → for efficient image layering</li></ul><p>Because of this, containers are:</p><ul><li>Lightweight</li><li>Fast to start</li><li>Highly portable across environments</li></ul><h3>Platform Behavior</h3><ul><li>On <strong>Linux</strong>, Docker runs natively using the host kernel</li><li>On <strong>Windows/macOS</strong>, Docker requires a <strong>Linux virtual machine</strong> to function</li></ul><h3>What is Docker Desktop?</h3><p>Docker Desktop is a <strong>developer-focused application</strong> that bundles Docker Engine with additional tools and a graphical interface.</p><p>It is specifically designed to simplify container usage on <strong>Windows and macOS</strong>.</p><h3>What It Includes</h3><p>Docker Desktop comes with:</p><ul><li>Docker Engine (pre-installed and configured)</li><li>Docker CLI</li><li>Docker Compose (for multi-container applications)</li><li>Built-in Kubernetes (optional)</li><li>GUI Dashboard for managing containers and images</li></ul><h3>Under the Hood</h3><p>Since containers rely on Linux kernel features, Docker Desktop uses a lightweight virtualization layer:</p><ul><li><strong>Windows</strong> → WSL 2 or Hyper-V</li><li><strong>macOS</strong> → HyperKit or Apple Virtualization Framework</li></ul><p>This VM runs transparently in the background, allowing developers to use Docker without manual setup.</p><h3>Architectural Difference</h3><p>The fundamental difference lies in <strong>how each is deployed and used</strong>:</p><ul><li><strong>Docker</strong> is the <strong>core container runtime</strong>, typically installed on Linux servers or cloud environments</li><li><strong>Docker Desktop</strong> is a <strong>packaged development environment</strong>, which runs Docker inside a managed virtual machine and adds usability features</li></ul><p>In simple terms:</p><blockquote><em>Docker = Engine<br>Docker Desktop = Engine + Tools + GUI + VM</em></blockquote><h3>Key Technical Differences</h3><p>AspectDockerDocker DesktopTypeContainer runtimeIntegrated development environmentArchitectureClient–server (CLI ↔ Daemon)Wrapper around Docker Engine + VMOS SupportNative on LinuxWindows &amp; macOSInterfaceCLI-basedGUI + CLIVirtualizationNot required (Linux)Required (WSL2 / HyperKit)KubernetesNot includedBuilt-in (optional)Primary UseProduction, serversLocal development</p><h3>When Should You Use Each?</h3><h3>Use Docker (Engine Only) When:</h3><ul><li>Deploying applications in <strong>production</strong></li><li>Running containers on <strong>Linux servers or cloud (e.g., AWS EC2)</strong></li><li>You need <strong>maximum performance with minimal overhead</strong></li></ul><h3>Use Docker Desktop When:</h3><ul><li>Developing applications locally on <strong>Windows or macOS</strong></li><li>You want an <strong>easy setup and user-friendly interface</strong></li><li>You are testing <strong>Kubernetes locally</strong></li></ul><h3>Why This Difference Matters</h3><p>Many beginners assume Docker Desktop <em>is</em> Docker. While Docker Desktop includes Docker, it also introduces:</p><ul><li>A virtualization layer</li><li>Additional tooling</li><li>A different runtime environment</li></ul><p>This distinction becomes important when:</p><ul><li>Debugging environment-specific issues</li><li>Deploying to production systems</li><li>Optimizing performance</li></ul><p>Understanding this separation helps you <strong>avoid the “it works on my machine” problem</strong>.</p><h3>Conclusion</h3><p>Docker and Docker Desktop serve different but complementary purposes in the container ecosystem.</p><ul><li><strong>Docker</strong> is the <strong>core technology</strong> that powers containerization</li><li><strong>Docker Desktop</strong> is a <strong>developer convenience tool</strong> that simplifies using Docker on non-Linux systems</li></ul><p>As a developer, you’ll typically:</p><ul><li>Use <strong>Docker Desktop</strong> for local development</li><li>Use <strong>Docker Engine</strong> in production environments</li></ul><p>Mastering both ensures a smoother transition from development to deployment — a critical skill in modern DevOps and cloud-native workflows.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4841ec99b51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Foreign Key with examples]]></title>
            <link>https://medium.com/@isharapeiris2001/understanding-foreign-key-with-examples-3bf91272fa88?source=rss-c4dfe35c7c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bf91272fa88</guid>
            <category><![CDATA[understanding-foreign-key]]></category>
            <category><![CDATA[foreign-key-sql]]></category>
            <dc:creator><![CDATA[Ishara Peiris]]></dc:creator>
            <pubDate>Wed, 16 Apr 2025 16:36:19 GMT</pubDate>
            <atom:updated>2025-04-16T16:36:19.055Z</atom:updated>
            <content:encoded><![CDATA[<p>When building relational databases, maintaining relationships between tables is crucial. This is where <strong>foreign keys</strong> come in. Let’s break it down.</p><p>What is foreign key</p><p>A <strong>foreign key</strong> is a column (or group of columns) in one table that <strong>references the primary key in another table</strong>. It is used to establish and enforce a <strong>link between the data in two tables</strong>.</p><p>It helps to</p><ul><li>Create <strong>relationships</strong> between tables</li><li>Maintain <strong>referential integrity</strong></li></ul><p>Example</p><p>student and course</p><p>student table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*UbfRQZerH15D0KgZicVUJg.png" /><figcaption>student_table</figcaption></figure><p>course table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*r_0kCxr_10DPLv0ArwAIvg.png" /><figcaption>course table</figcaption></figure><p>We now need a table to track which student is enrolled in which course. That’s where the <strong>foreign keys</strong> come in.</p><p>enrollments table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PsoohQfECaxhed-MJVsp5w.png" /><figcaption>enrollment_table</figcaption></figure><p>Here, Student_id in the Enrollment table is a <strong>foreign key</strong> that refers to Student(Student_id),<br> and Course_id is a <strong>foreign key</strong> that refers to Courses(Course_id).</p><p>now lets see how map this into sql</p><pre>CREATE TABLE Student (<br>    student_id INT PRIMARY KEY,<br>    name VARCHAR(100)<br>);<br><br>CREATE TABLE Courses (<br>    course_id INT PRIMARY KEY,<br>    course_name VARCHAR(100)<br>);<br><br>CREATE TABLE Enrollments (<br>    EnrollmentID INT PRIMARY KEY,<br>    student_id INT,<br>    course_id INT,<br>    FOREIGN KEY (student_id) REFERENCES Students(student_id),<br>    FOREIGN KEY (course_id) REFERENCES Courses(course_id)<br>);</pre><h3>Summary</h3><ul><li>A <strong>foreign key</strong> links two tables.</li><li>It ensures that a value in one table must exist in another.</li><li>Helps avoid <strong>invalid data</strong> and ensures <strong>data consistency</strong>.</li><li>You can customize behavior (like <strong>ON DELETE CASCADE</strong>) to handle changes gracefully.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n2zzWdJ04Bx7_i0xqpNeag.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bf91272fa88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OOP Without the Car: Understanding Object-Oriented Programming Through a Banking System]]></title>
            <link>https://medium.com/@isharapeiris2001/oop-without-the-car-understanding-object-oriented-programming-through-a-banking-system-771480cb4fc6?source=rss-c4dfe35c7c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/771480cb4fc6</guid>
            <dc:creator><![CDATA[Ishara Peiris]]></dc:creator>
            <pubDate>Sat, 12 Apr 2025 13:08:15 GMT</pubDate>
            <atom:updated>2025-04-12T13:08:15.791Z</atom:updated>
            <content:encoded><![CDATA[<p>Object-Oriented Programming (OOP) is a powerful programming concept used to design software around <strong>real-world entities</strong> and their <strong>interactions</strong>. While most tutorials love to talk about cars and vehicles, let’s spice it up with something different — <strong>banking!</strong> 💰</p><h3>1. What is Object-Oriented Programming (OOP)?</h3><p>Object-Oriented Programming (OOP) is a method of structuring a program by bundling related properties and behaviors into individual objects. It helps in organizing complex code, making it reusable, scalable, and easier to maintain.</p><p>in that case we have to identify real world entities as classes and objects.</p><p>Class and Object</p><p>A <strong>class</strong> is a blueprint for creating <strong>objects</strong>. Think of a class as a definition, and an object as a specific instance of that definition.</p><h3>🏦 Example: Bank Account</h3><pre>class BankAccount{<br>    account_number;<br>    balance;<br>    <br>    withdarw();<br>    deposite();<br>}</pre><h4>Creating an object</h4><pre>account1 = BankAccount(&quot;123456&quot;, 1000)<br>print(account1.withdraw());</pre><p>Here, BankAccount is a class. account1 is an object (a real account) created from that class.</p><h3>There are four main pillars of OOP:</h3><ul><li><strong>Encapsulation</strong></li><li><strong>Abstraction</strong></li><li><strong>Inheritance</strong></li><li><strong>Polymorphism</strong></li></ul><p>Let’s now explore each concept with examples from a banking system.</p><h3>1. Inheritance</h3><p>Inheritance allows one class to inherit properties and methods from another class. This helps to avoid repetition and promotes reusability.</p><h3>🧒👨 Example: Kids and Adult Bank Accounts</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*keXXu2ljQpKjY_KOoPZosQ.jpeg" /></figure><pre>class Bank_Account{<br>        account_number ;<br>        balance ;<br>        <br>        deposite();<br>}<br></pre><pre>  class Kids_Account extends Bank_Account{<br>             parentDetail;<br>            }</pre><pre>class Adult_Account{<br>            withdarw();<br>            applyLoan();<br>}<br></pre><p>KidsAccount and AdultAccount both inherit the basic features of BankAccount. But they also add their own features—kids accounts may have a guardian, and adults can apply for loans.</p><h3>2.Abstraction</h3><p>Abstraction means showing only the <strong>relevant details</strong> and hiding the complexity from the user.</p><h3>🏦 Example: ATM Interface</h3><p>When you use an ATM, you only see options like “Withdraw” or “Check Balance” — you don’t see the code behind how it connects to the database.</p><pre>from abc import ABC, abstractmethod</pre><pre>abstract class Account {<br>    abstract void withdraw(double amount);<br>    abstract void deposit(double amount);<br>}</pre><pre>class SavingsAccount extends Account {<br>    void withdraw(double amount) {<br>        // Logic to subtract from balance<br>    }</pre><pre>void deposit(double amount) {<br>        // Logic to add to balance<br>    }<br>}</pre><p>Here, Account is an abstract class. It defines a method withdraw but leaves the actual implementation to the subclasses like SavingsAccount.</p><h3>3.Polymorphism</h3><p>Polymorphism allows methods to do <strong>different things based on the object</strong> calling them, even if they share the same name.</p><h3>💳 Example: Different account types processing withdrawals differently</h3><pre>// Parent Class<br>class BankAccount {<br>    void calculateInterest() {<br>        // default logic<br>    }<br>}<br><br>// Child Class 1<br>class SavingsAccount extends BankAccount {<br>    void calculateInterest() {<br>        // 3% interest calculation<br>    }<br>}<br><br>// Child Class 2<br>class FixedDepositAccount extends BankAccount {<br>    void calculateInterest() {<br>        // 6% interest calculation<br>    }<br>}</pre><p>Now, when you call calculateInterest() on a SavingsAccount or FixedDepositAccount, it behaves <strong>differently</strong>. That’s <strong>polymorphism</strong>.</p><h3>✅ Real-life parallel:</h3><p>You tap your <strong>card</strong> at different machines:</p><ul><li>At a <strong>bus terminal</strong>, it pays for your ride.</li><li>At an <strong>ATM</strong>, it withdraws cash.</li><li>Same card → different behaviors = Polymorphism!</li></ul><h3>4.Encapsulation</h3><p>Encapsulation means hiding the internal state of an object and requiring all interactions to be performed through methods. This protects data integrity.</p><h3>🔐 Example: Private Balance</h3><pre>class BankAccount {<br>    private double balance;<br><br>    // Only allow controlled access<br>    public double getBalance() {<br>        return balance;<br>    }<br><br>    public void deposit(double amount) {<br>        if (amount &gt; 0) {<br>            balance += amount;<br>        }<br>    }<br>}</pre><ul><li>You <strong>cannot directly access</strong> balance from outside.</li><li>You <strong>must use</strong> getBalance() or deposit() → this protects the data.</li></ul><h3>✅ Real-life parallel:</h3><p>Think of an <strong>ATM</strong>:</p><ul><li>You <strong>can’t access</strong> the internal cash tray.</li><li>You can only <strong>withdraw money</strong> using buttons.</li></ul><h3>✨ Final Thoughts</h3><p>OOP isn’t just about objects and classes — it’s about designing systems that mirror the real world in a structured, scalable way. And guess what? You didn’t need a car to learn all that 😉</p><p>Whether you’re designing bank accounts, user systems, or anything else, mastering these OOP principles will make your code cleaner and more efficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/0*rz4qurhBPiJQkjPO.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=771480cb4fc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tariff Wars, Trade Tensions & Tech]]></title>
            <link>https://medium.com/@isharapeiris2001/tariff-wars-trade-tensions-tech-77f4cd333f14?source=rss-c4dfe35c7c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/77f4cd333f14</guid>
            <dc:creator><![CDATA[Ishara Peiris]]></dc:creator>
            <pubDate>Tue, 08 Apr 2025 18:52:20 GMT</pubDate>
            <atom:updated>2025-04-08T18:52:20.989Z</atom:updated>
            <content:encoded><![CDATA[<p>​On April 2, 2025, President Donald Trump announced a sweeping tariff policy imposing a <strong>10% tariff on all imports</strong> into the United States, with higher rates for countries with significant trade deficits, such as China, Mexico, and Vietnam.</p><p>The 2025 Global Tariff War — What’s Happening?</p><p>Tariff wars are nothing new. But this time, the <strong>stakes are higher</strong> and the <strong>rules are changing</strong>.</p><ul><li><strong>U.S. Tariffs</strong>: 10% on all imports; higher (up to 60%) on strategic sectors and goods from China, Mexico, and Vietnam etc.</li><li><strong>China’s Response</strong>: A <strong>34% tariff</strong> on U.S. exports, targeting agriculture, electronics, and automobile components.</li><li><strong>Other Countries React</strong>: The <strong>European Union</strong>, <strong>India</strong>, and <strong>Brazil</strong> have all hinted at retaliatory measures or are exploring strategic trade alliances to bypass U.S. dependency.</li></ul><h3><strong>The Software Industry — Caught in the Crossfire or Shielded?</strong></h3><p>At first glance, the <strong>software sector</strong> saw a sharp <strong>market reaction</strong>, with some smaller-cap software stocks falling by <strong>10% or more</strong>, rattling investor confidence.</p><p>But <strong>Bernstein analysts</strong> argue this was more <strong>panic than substance</strong>.</p><blockquote><em>“Directly, software is not going to be impacted by the U.S. tariffs or counter-tariffs,” the firm noted. “Unlike physical goods, software isn’t subject to customs duties — most of it is delivered via cloud, locally hosted, or digitally downloaded.”</em></blockquote><h3>Indirect Impacts</h3><p><strong>Macro Headwinds</strong>: Smaller tech firms may feel the pinch from reduced demand, funding volatility, and client cutbacks.</p><p><strong>Cloud Infrastructure</strong>: Data centers — reliant on imported chips, servers, and cooling equipment — face <strong>rising costs</strong>, potentially increasing service fees.</p><p><strong>R&amp;D Slowdown</strong>: Innovation could decelerate, particularly in <strong>AI</strong>, due to the rising cost of training infrastructure.</p><h3>The Silver Lining</h3><ul><li><strong>GenAI Tailwind</strong>: As companies look to automate and cut costs, <strong>Generative AI adoption</strong> could <strong>accelerate</strong>, with software playing a key role in transformation.</li><li><strong>Domestic Cloud Growth</strong>: Hyperscalers like AWS, Azure, and Google Cloud are <strong>well-positioned</strong> with localized infrastructure, already compliant with global regulations.</li></ul><h3>The Road Ahead — Software Must Stay Agile</h3><p>While the software industry may not feel the <strong>brunt of tariffs directly</strong>, it cannot afford complacency. Companies must:</p><ul><li>Diversify <strong>cloud regions and compliance</strong> strategies.</li><li>Accelerate <strong>automation</strong> and <strong>cost optimization</strong>.</li><li>Prepare for <strong>regulatory changes</strong> across markets.</li><li>Watch for geopolitical shifts impacting <strong>digital infrastructure</strong> (e.g., rare earth minerals, semiconductor supply, etc.).</li></ul><h3>Final Thoughts</h3><p>The 2025 American tariff policy has undeniably shaken global trade foundations. While manufacturing and agriculture face immediate disruption, software stands as a strategic exception — not immune, but adaptable and agile. It’s becoming clear that in this new digital economy, the battleground is no longer just ports and factories — it’s cloud regions, data policies, and artificial intelligence.In a world of trade wars and economic uncertainty, code may be the new gold.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*nai85yrTurs-UFMtW2ROWg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77f4cd333f14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Fast and Scalable APIs with the Gin Framework in Golang]]></title>
            <link>https://medium.com/@isharapeiris2001/building-fast-and-scalable-apis-with-the-gin-framework-in-golang-c1895be3e7dc?source=rss-c4dfe35c7c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1895be3e7dc</guid>
            <dc:creator><![CDATA[Ishara Peiris]]></dc:creator>
            <pubDate>Sat, 05 Apr 2025 05:11:57 GMT</pubDate>
            <atom:updated>2025-04-05T05:11:57.162Z</atom:updated>
            <content:encoded><![CDATA[<p>Golang, also known as Go, is an open-source programming language developed by Google. Known for its simplicity, efficiency, and excellent support for concurrency, Go has become a popular choice for backend developers. One of the most widely-used frameworks built for Go is <strong>Gin</strong>. In this article, we’ll explore the <strong>Gin framework</strong>, how it helps you build fast and scalable web applications, and walk through a simple example of using it to build a basic API.</p><p>What is Gin?</p><p>Gin is a <strong>lightweight web framework</strong> for Go, designed to provide a fast and simple way to build web applications and RESTful APIs. Its main focus is <strong>performance</strong>, making it one of the fastest frameworks available for Go. Gin provides a range of features such as routing, middleware support, JSON validation, and more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/0*raKidSxxo8nIVRDP" /></figure><p>Step 1: Install Golang</p><p><a href="https://golang.org/doc/install">Download and install - The Go Programming Language</a></p><p>Step 2: Install Gin</p><pre>go get -u github.com/gin-gonic/gin</pre><p>Step 3: Set Up Your Project</p><pre>mkdir my-gin-api<br>cd my-gin-api</pre><p>Initialize Go module</p><pre>go mod init my-gin-api</pre><p>Handling HTTP Requests</p><p>In the Gin framework, r.GET, r.POST, r.PUT, r.DELETE, etc. are <strong>methods</strong> (functions) on the Gin router object — which you created with :r is a variable that holds the <strong>router instance</strong></p><pre>r := gin.Default()</pre><ol><li>GET request</li></ol><pre>package main<br><br>import &quot;github.com/gin-gonic/gin&quot;<br><br>func main() {<br>    r := gin.Default()<br><br>    // GET request<br>    r.GET(&quot;/users&quot;, func(c *gin.Context) {<br>        c.JSON(200, gin.H{&quot;message&quot;: &quot;GET request to /users&quot;})<br>    })</pre><p>this will Retrieves a list of users with the url /users.</p><p>2.POST Request</p><pre>r.POST(&quot;/users&quot;, func(c *gin.Context) {<br>        var user map[string]interface{}<br>        if err := c.BindJSON(&amp;user); err != nil {<br>            c.JSON(400, gin.H{&quot;error&quot;: &quot;Invalid request&quot;})<br>            return<br>        }<br>        c.JSON(201, gin.H{&quot;message&quot;: &quot;User created&quot;, &quot;user&quot;: user})<br>    })</pre><p>3.PUT request</p><pre> r.PUT(&quot;/users/:id&quot;, func(c *gin.Context) {<br>        id := c.Param(&quot;id&quot;)<br>        c.JSON(200, gin.H{&quot;message&quot;: &quot;Updated user&quot;, &quot;id&quot;: id})<br>    })</pre><p>4.Delete</p><pre>  r.DELETE(&quot;/users/:id&quot;, func(c *gin.Context) {<br>        id := c.Param(&quot;id&quot;)<br>        c.JSON(200, gin.H{&quot;message&quot;: &quot;Deleted user&quot;, &quot;id&quot;: id})<br>    })</pre><p>Use curl to test the API</p><p>example 1:Test POST api</p><pre>curl -X POST http://localhost:8080/users -d &#39;{&quot;name&quot;: &quot;Peiris&quot;, &quot;email&quot;: &quot;peiris@example.com&quot;}&#39; -H &quot;Content-Type: application/json&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*mU_21O1nEMBCl0t3.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1895be3e7dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Query Parameters vs API Route Parameters using Golang]]></title>
            <link>https://medium.com/@isharapeiris2001/query-parameters-vs-api-route-parameters-using-golang-931ad87151dd?source=rss-c4dfe35c7c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/931ad87151dd</guid>
            <dc:creator><![CDATA[Ishara Peiris]]></dc:creator>
            <pubDate>Thu, 27 Mar 2025 08:40:27 GMT</pubDate>
            <atom:updated>2025-04-06T17:12:12.301Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*889z6hxc1WLTdkHHxxPDsw.png" /></figure><h3>Query Parameters</h3><p>Query parameters are used to send optional data in the URL. They are typically used for filtering, searching, and sorting data.</p><p>this is fetch a user who has id 1</p><pre>https://example.com/users?id=1 </pre><h3>Path Parameters</h3><p>Path parameters are used when data is part of the URL structure, usually representing a unique identifier for a resource.</p><p>we can define Path Variable as one of the passing data method.</p><pre>https://example.com/user/1</pre><p>in golang we can use query paramerters like this</p><pre>package main<br><br>import (<br> &quot;fmt&quot;<br> &quot;net/http&quot;<br>)<br><br>func queryHandler(w http.ResponseWriter, r *http.Request) {<br> // Parse query parameters<br> query := r.URL.Query()<br> name := query.Get(&quot;name&quot;)<br> age := query.Get(&quot;age&quot;)<br><br> fmt.Fprintf(w, &quot;Hello, %s! Your age is %s.&quot;, name, age)<br>}<br><br>func main() {<br> http.HandleFunc(&quot;/query&quot;, queryHandler)<br> fmt.Println(&quot;Server running on http://localhost:8080&quot;)<br> http.ListenAndServe(&quot;:8080&quot;, nil)<br>}</pre><p>how to test</p><pre>http://localhost:8080/query?name=John&amp;age=25</pre><p>the result will be</p><pre>Hello, John! Your age is 25.</pre><p>in go we can use path parameters like this</p><pre>package main<br><br>import (<br> &quot;fmt&quot;<br> &quot;net/http&quot;<br> &quot;strings&quot;<br>)<br><br>func pathHandler(w http.ResponseWriter, r *http.Request) {<br> // Get path segments<br> path := strings.TrimPrefix(r.URL.Path, &quot;/user/&quot;)<br> fmt.Fprintf(w, &quot;User ID: %s&quot;, path)<br>}<br><br>func main() {<br> http.HandleFunc(&quot;/user/&quot;, pathHandler)<br> fmt.Println(&quot;Server running on http://localhost:8080&quot;)<br> http.ListenAndServe(&quot;:8080&quot;, nil)<br>}</pre><p>how to run</p><pre>http://localhost:8080/user/123</pre><p>result would be</p><pre>User ID: 123</pre><p>When to use path or query</p><p>As a best practice</p><p>If you want to identify a resource, you should use Path Variable. But if you want to sort or filter items, then you should use query parameter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=931ad87151dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTTP, URL & IP Addresses Explained for IT Beginners]]></title>
            <link>https://medium.com/@isharapeiris2001/http-url-ip-addresses-explained-for-it-beginners-bbdd90e29089?source=rss-c4dfe35c7c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbdd90e29089</guid>
            <dc:creator><![CDATA[Ishara Peiris]]></dc:creator>
            <pubDate>Fri, 21 Mar 2025 12:06:04 GMT</pubDate>
            <atom:updated>2025-03-21T12:06:04.244Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding HTTP</h3><h3>The Bridge Between Frontend and Backend</h3><p>When building a web application, the frontend and backend need a way to communicate. Think of it like a pipeline connecting two systems — this is where protocols come in.</p><p>One of the most widely used protocols is <strong>HTTP (HyperText Transfer Protocol)</strong>. Simply put, HTTP is the standard protocol for transferring hypertext files, which are essentially linked documents.</p><p>In this setup, the <strong>browser (frontend)</strong> is called the <strong>client</strong>, while the <strong>backend</strong> is referred to as the <strong>server application</strong>. Whenever the client needs to fetch or save data, it sends an <strong>HTTP request</strong> (e.g., GET or POST). The server then processes the request and returns a response, known as the <strong>HTTP response</strong>.</p><p>This request-response cycle is the foundation of web communication, allowing users to interact with websites seamlessly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*beYH7dfvA14Lc8sGORvn0w.png" /><figcaption>Understanding HTTP</figcaption></figure><h3>Understanding URLs: How They Work</h3><p>A <strong>URL (Uniform Resource Locator)</strong> is like an address for locating resources on the internet. It tells your browser <strong>where</strong> to go and <strong>how</strong> to access a resource.</p><h3>Breaking Down a URL</h3><p>Let’s take an example:</p><p>👉 <a href="https://google.com:80/"><strong>https://google.com:80</strong></a></p><p>Here’s what each part means:</p><ul><li><strong>https://</strong> → The <strong>protocol</strong>, which defines how data is transmitted.</li><li>http:// = Standard HyperText Transfer Protocol.</li><li>https:// = Secure HTTP (uses encryption with SSL/TLS).</li><li><strong>google.com</strong> → The <strong>hostname</strong> (domain name) that identifies the server.</li><li><strong>:80</strong> → The <strong>port number</strong> where the request is sent.</li><li>80 is the default port for <strong>HTTP</strong>.</li><li>443 is the default port for <strong>HTTPS</strong>.</li></ul><p>When you type google.com in your browser, it <strong>automatically assumes</strong> https://google.com and connects via <strong>port 443</strong> for security.</p><h3>Localhost and Custom Ports</h3><p>If you’re running a local web server, the URL might look like this:</p><p>👉 <a href="http://localhost:3000/"><strong>http://localhost:3000</strong></a></p><ul><li><strong>localhost</strong> → Refers to your own computer as the server.</li><li><strong>3000</strong> → The <strong>port number</strong>, which can vary depending on your application. Common ports include:</li><li>3000 → Often used for Node.js apps.</li><li>8000 / 8080 → Used by PHP, Apache, or development servers.</li></ul><h3>Why Are URLs Important?</h3><p>A URL helps browsers and applications locate resources like <strong>webpages, images, videos, and APIs</strong>. It identifies the <strong>server</strong> hosting the resource, but it does <strong>not</strong> directly identify the client making the request.</p><h3>Understanding IP Addresses</h3><p>A <strong>hostname</strong> (like google.com) is human-readable, but computers don’t understand names—they need <strong>IP addresses</strong> to communicate.</p><p>An <strong>IP address</strong> (Internet Protocol Address) is a unique number assigned to each device on a network. It helps computers find and connect to each other, just like a home address.</p><p>For example:</p><ul><li>google.com (Hostname) → 142.250.190.14 (IP Address)</li></ul><h3>Why Do We Need IP Addresses?</h3><p>When you type a website name in your browser, a system called <strong>DNS (Domain Name System)</strong> translates it into an IP address so your device can find the correct server.</p><h3>Types of IP Addresses</h3><ul><li><strong>IPv4</strong> → Uses numbers like 192.168.1.1 (common but limited).</li><li><strong>IPv6</strong> → Uses longer addresses like 2001:db8::ff00:42:8329 (for more devices).</li><li>for localhost 127.0.0.1</li></ul><p>Every device, from your phone to a web server, has an IP address so it can send and receive information over the internet.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbdd90e29089" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Data Structures and Algorithms: A Guide for Efficient Problem-Solving]]></title>
            <link>https://medium.com/@isharapeiris2001/mastering-data-structures-and-algorithms-a-guide-for-efficient-problem-solving-00cbce705599?source=rss-c4dfe35c7c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/00cbce705599</guid>
            <dc:creator><![CDATA[Ishara Peiris]]></dc:creator>
            <pubDate>Fri, 31 Jan 2025 05:56:01 GMT</pubDate>
            <atom:updated>2025-01-31T05:56:01.127Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of computer science, <strong>Data Structures and Algorithms (DSA)</strong> form the backbone of efficient programming and problem-solving.</p><h3>1. What Are Data Structures?</h3><p>A <strong>data structure</strong> is a way of organizing and storing data.</p><h4>Types of Data Structures</h4><h4>Linear Data Structures:</h4><ol><li><strong>Arrays</strong> — A collection of elements stored in contiguous memory locations.</li><li><strong>Linked Lists</strong> — A sequence of nodes where each node contains a value and a pointer to the next node.</li><li><strong>Stacks</strong> — A last-in, first-out (LIFO) structure used in recursion and backtracking.</li><li><strong>Queues</strong> — A first-in, first-out (FIFO) structure, useful for scheduling and task management.</li></ol><h3>Non-Linear Data Structures:</h3><ol><li><strong>Trees</strong> — A hierarchical structure used in databases, file systems, and decision-making algorithms.</li><li><strong>Graphs</strong> — A collection of nodes and edges, commonly used in social networks, navigation, and AI.</li><li><strong>Hash Tables</strong> — A key-value storage system used for fast data retrieval (e.g., dictionaries in Python).</li><li><strong>Heaps</strong> — A specialized tree-based structure used in priority queues and heap sort.</li></ol><h3>What Are Algorithms?</h3><p>An <strong>algorithm</strong> is a step-by-step procedure for solving a problem.</p><h3>Types of Algorithms:</h3><h4>Searching Algorithms:</h4><ol><li><strong>Linear Search</strong> — Sequentially checks each element until the target is found.</li><li><strong>Binary Search</strong> — Efficient search for sorted arrays with O(log n) complexity.</li></ol><h4>Sorting Algorithms:</h4><ol><li><strong>Bubble Sort</strong> — Simple but inefficient (O(n²)).</li><li><strong>Merge Sort</strong> — A divide-and-conquer algorithm with O(n log n) complexity.</li><li><strong>Quick Sort</strong> — A fast sorting method using partitioning.</li><li><strong>Insertion Sort</strong> — Good for nearly sorted data.</li></ol><h4>Graph Algorithms:</h4><ol><li><strong>Breadth-First Search (BFS)</strong> — Used for shortest path and network traversal.</li><li><strong>Depth-First Search (DFS)</strong> — Used in puzzles, maze solving, and spanning trees.</li><li><strong>Dijkstra’s Algorithm</strong> — Finds the shortest path in weighted graphs.</li></ol><h4>Dynamic Programming (DP):</h4><ol><li><strong>Fibonacci Sequence</strong> — Optimized using memoization.</li><li><strong>Knapsack Problem</strong> — Used in resource allocation and budgeting.</li></ol><h3>Choosing the Right Data Structure</h3><p>Selecting the right data structure depends on:</p><ul><li><strong>Time Complexity:</strong> How fast operations like insertion, deletion, and searching perform.</li><li><strong>Space Complexity:</strong> How much memory is required.</li><li><strong>Use Case:</strong> Whether the data needs quick access, sorting, or hierarchical storage.</li></ul><p>For example:</p><ul><li><strong>Use an array</strong> when you need fast index-based access.</li><li><strong>Use a linked list</strong> when you need dynamic memory allocation.</li><li><strong>Use a stack</strong> when managing function calls (e.g., recursion).</li><li><strong>Use a queue</strong> when processing tasks in order.</li><li><strong>Use a graph</strong> when modeling relationships (e.g., social networks).</li></ul><h3>Big-O Notation and Complexity Analysis</h3><p>Big-O notation helps analyze the performance of an algorithm in terms of time and space.</p><h3>Common Complexities:</h3><ul><li><strong>O(1)</strong> — Constant time (best case, hash table lookup).</li><li><strong>O(log n)</strong> — Logarithmic time (binary search).</li><li><strong>O(n)</strong> — Linear time (linear search).</li><li><strong>O(n log n)</strong> — Log-linear time (merge sort, quicksort).</li><li><strong>O(n²)</strong> — Quadratic time (bubble sort, selection sort).</li><li><strong>O(2ⁿ)</strong> — Exponential time (brute-force recursion).</li></ul><h3>Real-World Applications of DSA</h3><p>Data Structures and Algorithms are used in:</p><ul><li><strong>Search Engines (Google, Bing)</strong> — Uses hashing, trees, and graph traversal.</li><li><strong>Social Media Platforms (Facebook, Twitter)</strong> — Uses graphs for user connections and recommendations.</li><li><strong>Navigation Systems (Google Maps, Uber)</strong> — Uses graph algorithms like Dijkstra’s shortest path.</li><li><strong>Databases (MySQL, MongoDB)</strong> — Uses B-trees for indexing and fast retrieval.</li><li><strong>E-commerce (Amazon, eBay)</strong> — Uses sorting, searching, and recommendation systems</li></ul><h3>Conclusion</h3><p>Mastering Data Structures and Algorithms is essential for becoming a proficient programmer. It enhances problem-solving skills, improves code efficiency, and prepares you for technical interviews and real-world applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hnoi3_tG-87QQOp5.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00cbce705599" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[YouTube Thumbnail Strategies]]></title>
            <link>https://medium.com/@isharapeiris2001/youtube-thumbnail-strategies-8c1e14fcc6e3?source=rss-c4dfe35c7c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c1e14fcc6e3</guid>
            <dc:creator><![CDATA[Ishara Peiris]]></dc:creator>
            <pubDate>Wed, 25 Dec 2024 12:06:44 GMT</pubDate>
            <atom:updated>2024-12-25T12:06:44.913Z</atom:updated>
            <content:encoded><![CDATA[<p>Clickbait Titles</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qUuo_wI8acHjizRp0CQSpQ.png" /></figure><h3>1. “You Won’t Believe …”</h3><p>These titles play on curiosity and shock value, enticing readers to click to find out more.</p><ul><li><em>Examples:</em></li><li>“You Won’t Believe What This</li><li>“Things You Won’t Believe</li><li>“You Won’t Believe</li></ul><p><strong>Why It Works:</strong> It creates suspense and triggers FOMO (Fear of Missing Out).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o_qSEwfJOpV3xph_wo8k3w.png" /><figcaption>Example thumbnail</figcaption></figure><h3>2.“You Can Now …”</h3><p>This format is empowering, implying that something previously unavailable is now accessible.</p><ul><li><em>Examples:</em></li><li>“You Can Now Eat These Delicious Meals Without Gaining Weight!”</li></ul><p><strong>Why It Works:</strong> It creates excitement and hope by offering solutions or opportunities.</p><p>3.3. “n Reasons Why …”</p><p>This title format promises clear, concise takeaways in a structured list.</p><ul><li><em>Examples:</em></li><li>“3 Big Reasons Why You Should Stop Drinking Sugary Drinks Today.”</li><li>“5 Reasons Why Dogs Are the Best Companions.”</li><li>“10 Reasons Why Your Diet Isn’t Working — And How to Fix It!”</li></ul><p><strong>Why It Works:</strong> It appeals to people’s need for logic and easily digestible information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZaCdWdmq02zig-6wUA8NFA.png" /></figure><h3>4. “n Things …”</h3><p>This structure highlights specific actions or facts that people can relate to or learn from.</p><ul><li><em>Examples:</em></li><li>“7 Things You’re Doing Wrong Every Morning Without Realizing.”</li></ul><p><strong>Why It Works:</strong> It teases practical, relatable insights that readers don’t want to miss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rc9ezxZ8VBsc7pmESAF3Fg.png" /></figure><h3>5. “This Is What/How/Why …”</h3><p>These titles promise an explanation or a surprising reveal.</p><ul><li><em>Examples:</em></li><li>“This Is Why You Can’t Fall Asleep at Night.”</li></ul><p><strong>Why It Works:</strong> It sparks curiosity by suggesting an answer to a common question or mystery.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KxSpQd1g0frit8xrt0r-rA.png" /></figure><h3>6.“You Should/Stop Doing …”</h3><p>This format appeals to the reader’s desire to avoid mistakes or improve themselves.</p><ul><li><em>Examples:</em></li><li>“You Should Stop Making These Mistakes While Cooking Pasta.”</li></ul><p><strong>Why It Works:</strong> It offers actionable advice while triggering fear of consequences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5GaeDKLCmA9PJbe2PjKCsw.png" /></figure><h3>Tips for Writing Effective Clickbait Titles</h3><ol><li><strong>Use Numbers:</strong> Lists and numbered titles perform better as they promise clear, structured content.</li></ol><ul><li>Example: “7 Hidden Features of Your Smartphone You Didn’t Know About.”</li></ul><p><strong>2. Create Suspense:</strong> Leave the main detail unresolved in the title.</p><ul><li>Example: “The One Thing Successful People Do Every Morning.”</li></ul><p><strong>3. Address the Reader Directly:</strong> Use “You” to make it personal.</p><ul><li>Example: “You’re Wasting Money by Ignoring This Simple Hack.”</li></ul><p><strong>4. Offer a Benefit or Solution:</strong> Promise something valuable in the title.</p><ul><li>Example: “How to Lose Weight Without Giving Up Your Favorite Foods.”</li></ul><p><strong>5. Use Emotional Triggers:</strong> Appeal to surprise, joy, anger, or fear.</p><ul><li>Example: “Parents Are Furious About This New School Policy.”</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c1e14fcc6e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Payment System using Stripe]]></title>
            <link>https://medium.com/@isharapeiris2001/laravel-payment-system-using-stripe-9723774317d1?source=rss-c4dfe35c7c75------2</link>
            <guid isPermaLink="false">https://medium.com/p/9723774317d1</guid>
            <dc:creator><![CDATA[Ishara Peiris]]></dc:creator>
            <pubDate>Mon, 23 Dec 2024 18:09:29 GMT</pubDate>
            <atom:updated>2024-12-23T18:09:29.900Z</atom:updated>
            <content:encoded><![CDATA[<p>Handling online payments is a crucial feature for many web applications.I’ll guide you through the process of integrating Stripe into your Laravel application step by step.</p><ol><li>Step 1- Install the Stripe PHP Library Using Composer</li></ol><p>you need to run following command in your terminal.</p><pre>composer require stripe/stripe-php</pre><p>2. create a stripe account</p><p>Create new account on stripe by visiting <a href="https://stripe.com/">https://stripe.com/</a> or simply log in if you have account.</p><p>Then go to Developer section&gt;API keys.so there you can see the Publishable key and secret key.</p><p>3.step 3- change the .env file</p><p>now copy and paste your publishable key and secret key in .env file as follows.</p><pre>STRIPE_KEY=paste your publishable key<br><br>STRIPE_SECRET=paste your secret key</pre><p>4.Make route</p><p>in your web.php file add route. in my case Controller name is HomeController.</p><pre>route::get(&#39;/stripe/{totalprice}&#39;,[HomeController::class,&#39;stripe&#39;]);</pre><p>5.Link route to the Pay button</p><p>In your cart blade file the button option ‘pay using card’ should link to the route which we coded.</p><pre>&lt;a href=&quot;{{url(https://medium.com/&#39;stripe&#39;,$totalprice)}}&quot; class=&quot;btn -btn-danger&quot;&gt;Pay using Card&lt;/a&gt;</pre><p>5.create view file for rendering the view.In my case the folder is home/stripe.blade.php</p><pre>&lt;!DOCTYPE html&gt;<br><br>&lt;html&gt;<br><br>&lt;head&gt;<br>    &lt;base href=&quot;/public&quot;&gt;<br>    &lt;title&gt;&lt;/title&gt;<br><br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css&quot; /&gt;<br><br>    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js&quot;&gt;&lt;/script&gt;<br><br>    &lt;link rel=&quot;shortcut icon&quot; href=&quot;images/favicon.png&quot; type=&quot;&quot;&gt;<br>      &lt;title&gt;stripe&lt;/title&gt;<br>      &lt;!-- bootstrap core css --&gt;<br>      &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;home/css/bootstrap.css&quot; /&gt;<br>      &lt;!-- font awesome style --&gt;<br>      &lt;link href=&quot;home/css/font-awesome.min.css&quot; rel=&quot;stylesheet&quot; /&gt;<br>      &lt;!-- Custom styles for this template --&gt;<br>      &lt;link href=&quot;home/css/style.css&quot; rel=&quot;stylesheet&quot; /&gt;<br>      &lt;!-- responsive style --&gt;<br>      &lt;link href=&quot;home/css/responsive.css&quot; rel=&quot;stylesheet&quot; /&gt;<br><br>&lt;/head&gt;<br><br>&lt;body&gt;<br><br>&lt;div class=&quot;container&quot;&gt;<br><br>    &lt;h1&gt;Pay Using Your Card - Total Amount ${{$totalprice}}&lt;/h1&gt;<br><br><br><br>    &lt;div class=&quot;row&quot;&gt;<br><br>        &lt;div class=&quot;col-md-6 col-md-offset-3&quot;&gt;<br><br>            &lt;div class=&quot;panel panel-default credit-card-box&quot;&gt;<br><br>                &lt;div class=&quot;panel-heading display-table&quot; &gt;<br><br>                        &lt;h3 class=&quot;panel-title&quot; &gt;Payment Details&lt;/h3&gt;<br><br>                &lt;/div&gt;<br><br>                &lt;div class=&quot;panel-body&quot;&gt;<br><br><br><br>                    @if (Session::has(&#39;success&#39;))<br><br>                        &lt;div class=&quot;text-center alert alert-success&quot;&gt;<br><br>                            &lt;a href=&quot;#&quot; class=&quot;close&quot; data-dismiss=&quot;alert&quot; aria-label=&quot;close&quot;&gt;×&lt;/a&gt;<br><br>                            &lt;p&gt;{{ Session::get(&#39;success&#39;) }}&lt;/p&gt;<br><br>                        &lt;/div&gt;<br><br>                    @endif<br><br><br><br>                    &lt;form<br><br>                            role=&quot;form&quot;<br><br>                            action=&quot;{{ route(&#39;stripe.post&#39;, $totalprice) }}&quot;<br><br>                            method=&quot;post&quot;<br><br>                            class=&quot;require-validation&quot;<br><br>                            data-cc-on-file=&quot;false&quot;<br><br>                            data-stripe-publishable-key=&quot;{{ env(&#39;STRIPE_KEY&#39;) }}&quot;<br><br>                            id=&quot;payment-form&quot;&gt;<br><br>                        @csrf<br><br><br><br>                        &lt;div class=&#39;form-row row&#39;&gt;<br><br>                            &lt;div class=&#39;col-xs-12 form-group required&#39;&gt;<br><br>                                &lt;label class=&#39;control-label&#39;&gt;Name on Card&lt;/label&gt; &lt;input<br><br>                                    class=&#39;form-control&#39; size=&#39;4&#39; type=&#39;text&#39;&gt;<br><br>                            &lt;/div&gt;<br><br>                        &lt;/div&gt;<br><br><br><br>                        &lt;div class=&#39;form-row row&#39;&gt;<br><br>                            &lt;div class=&#39;col-xs-12 form-group card required&#39;&gt;<br><br>                                &lt;label class=&#39;control-label&#39;&gt;Card Number&lt;/label&gt; &lt;input<br><br>                                    autocomplete=&#39;off&#39; class=&#39;form-control card-number&#39; size=&#39;20&#39;<br><br>                                    type=&#39;text&#39;&gt;<br><br>                            &lt;/div&gt;<br><br>                        &lt;/div&gt;<br><br><br><br>                        &lt;div class=&#39;form-row row&#39;&gt;<br><br>                            &lt;div class=&#39;col-xs-12 col-md-4 form-group cvc required&#39;&gt;<br><br>                                &lt;label class=&#39;control-label&#39;&gt;CVC&lt;/label&gt; &lt;input autocomplete=&#39;off&#39;<br><br>                                    class=&#39;form-control card-cvc&#39; placeholder=&#39;ex. 311&#39; size=&#39;4&#39;<br><br>                                    type=&#39;text&#39;&gt;<br><br>                            &lt;/div&gt;<br><br>                            &lt;div class=&#39;col-xs-12 col-md-4 form-group expiration required&#39;&gt;<br><br>                                &lt;label class=&#39;control-label&#39;&gt;Expiration Month&lt;/label&gt; &lt;input<br><br>                                    class=&#39;form-control card-expiry-month&#39; placeholder=&#39;MM&#39; size=&#39;2&#39;<br><br>                                    type=&#39;text&#39;&gt;<br><br>                            &lt;/div&gt;<br><br>                            &lt;div class=&#39;col-xs-12 col-md-4 form-group expiration required&#39;&gt;<br><br>                                &lt;label class=&#39;control-label&#39;&gt;Expiration Year&lt;/label&gt; &lt;input<br><br>                                    class=&#39;form-control card-expiry-year&#39; placeholder=&#39;YYYY&#39; size=&#39;4&#39;<br><br>                                    type=&#39;text&#39;&gt;<br><br>                            &lt;/div&gt;<br><br>                        &lt;/div&gt;<br><br><br><br>                        &lt;div class=&#39;form-row row&#39;&gt;<br><br>                            &lt;div class=&#39;col-md-12 error form-group hide&#39;&gt;<br><br>                                &lt;div class=&#39;alert-danger alert&#39;&gt;Please correct the errors and try<br><br>                                    again.&lt;/div&gt;<br><br>                            &lt;/div&gt;<br><br>                        &lt;/div&gt;<br><br><br><br>                        &lt;div class=&quot;row&quot;&gt;<br><br>                            &lt;div class=&quot;col-xs-12&quot;&gt;<br><br>                                &lt;button class=&quot;btn btn-primary btn-lg btn-block&quot; type=&quot;submit&quot;&gt;Pay Now &lt;/button&gt;<br><br>                            &lt;/div&gt;<br><br>                        &lt;/div&gt;<br><br><br><br>                    &lt;/form&gt;<br><br>                &lt;/div&gt;<br><br>            &lt;/div&gt;<br><br>        &lt;/div&gt;<br><br>    &lt;/div&gt;<br><br><br><br>&lt;/div&gt;<br><br><br><br>&lt;/body&gt;<br><br><br><br>&lt;script type=&quot;text/javascript&quot; src=&quot;https://js.stripe.com/v2/&quot;&gt;&lt;/script&gt;<br><br><br><br>&lt;script type=&quot;text/javascript&quot;&gt;<br><br><br><br>$(function() {<br><br><br><br>    /*------------------------------------------<br><br>    --------------------------------------------<br><br>    Stripe Payment Code<br><br>    --------------------------------------------<br><br>    --------------------------------------------*/<br><br><br><br>    var $form = $(&quot;.require-validation&quot;);<br><br><br><br>    $(&#39;form.require-validation&#39;).bind(&#39;submit&#39;, function(e) {<br><br>        var $form = $(&quot;.require-validation&quot;),<br><br>        inputSelector = [&#39;input[type=email]&#39;, &#39;input[type=password]&#39;,<br><br>                         &#39;input[type=text]&#39;, &#39;input[type=file]&#39;,<br><br>                         &#39;textarea&#39;].join(&#39;, &#39;),<br><br>        $inputs = $form.find(&#39;.required&#39;).find(inputSelector),<br><br>        $errorMessage = $form.find(&#39;div.error&#39;),<br><br>        valid = true;<br><br>        $errorMessage.addClass(&#39;hide&#39;);<br><br><br><br>        $(&#39;.has-error&#39;).removeClass(&#39;has-error&#39;);<br><br>        $inputs.each(function(i, el) {<br><br>          var $input = $(el);<br><br>          if ($input.val() === &#39;&#39;) {<br><br>            $input.parent().addClass(&#39;has-error&#39;);<br><br>            $errorMessage.removeClass(&#39;hide&#39;);<br><br>            e.preventDefault();<br><br>          }<br><br>        });<br><br><br><br>        if (!$form.data(&#39;cc-on-file&#39;)) {<br><br>          e.preventDefault();<br><br>          Stripe.setPublishableKey($form.data(&#39;stripe-publishable-key&#39;));<br><br>          Stripe.createToken({<br><br>            number: $(&#39;.card-number&#39;).val(),<br><br>            cvc: $(&#39;.card-cvc&#39;).val(),<br><br>            exp_month: $(&#39;.card-expiry-month&#39;).val(),<br><br>            exp_year: $(&#39;.card-expiry-year&#39;).val()<br><br>          }, stripeResponseHandler);<br><br>        }<br><br><br><br>    });<br><br><br><br>    /*------------------------------------------<br><br>    --------------------------------------------<br><br>    Stripe Response Handler<br><br>    --------------------------------------------<br><br>    --------------------------------------------*/<br><br>    function stripeResponseHandler(status, response) {<br><br>        if (response.error) {<br><br>            $(&#39;.error&#39;)<br><br>                .removeClass(&#39;hide&#39;)<br><br>                .find(&#39;.alert&#39;)<br><br>                .text(response.error.message);<br><br>        } else {<br><br>            /* token contains id, last4, and card type */<br><br>            var token = response[&#39;id&#39;];<br><br><br><br>            $form.find(&#39;input[type=text]&#39;).empty();<br><br>            $form.append(&quot;&lt;input type=&#39;hidden&#39; name=&#39;stripeToken&#39; value=&#39;&quot; + token + &quot;&#39;/&gt;&quot;);<br><br>            $form.get(0).submit();<br><br>        }<br><br>    }<br><br><br><br>});<br><br>&lt;/script&gt;<br><br>&lt;/html&gt;</pre><p>6.Make controller function</p><p>to return the stripe.blade.php file</p><pre>public function stripe($totalprice){<br>        return view(&#39;home.stripe&#39;,compact(&#39;totalprice&#39;));<br>    }</pre><p>7.make the route</p><p>write the post method route for handle data submittion</p><pre>route::post(&#39;stripe/{totalprice}&#39;, [HomeController::class,&#39;stripePost&#39;])-&gt;name(&#39;s<br>tripe.post&#39;);</pre><p>8.Contoller function</p><p>In your controller write the code for stripePost method .</p><p>Note:Do not forget to include @the top of your controller:</p><p>use Session;</p><p>use Stripe;</p><pre>public function stripePost(Request $request,$totalprice)<br><br>    {<br>       <br>        Stripe\Stripe::setApiKey(env(&#39;STRIPE_SECRET&#39;));<br><br>    <br><br>        Stripe\Charge::create ([<br><br>                &quot;amount&quot; =&gt; $totalprice * 100,<br><br>                &quot;currency&quot; =&gt; &quot;usd&quot;,<br><br>                &quot;source&quot; =&gt; $request-&gt;stripeToken,<br><br>                &quot;description&quot; =&gt; &quot;Thanks for the Payment&quot; <br><br>        ]);<br><br>      <br><br>        Session::flash(&#39;success&#39;, &#39;Payment successful!&#39;);<br><br>              <br><br>        return back();<br><br>    }</pre><p>9.Testing</p><p>now you should be able to get the view of the checkout page as this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*rA6tcAo4F6LEK3KAnpERZQ.png" /></figure><p>check with these credentials</p><pre>Name: Test</pre><pre>Number: 4242 4242 4242 4242</pre><pre>CSV: 123</pre><pre>Expiration Month: 12</pre><pre>Expiration Year: 2028</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNuI-hUZL5yhQcXe6vbjXQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9723774317d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>