<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Akrem Chabchoub</title>
    <description>The latest articles on DEV Community by Akrem Chabchoub (@akremchabchoub).</description>
    <link>https://dev.to/akremchabchoub</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1090694%2F1cf8663f-2673-4204-919e-2d404caee691.jpg</url>
      <title>DEV Community: Akrem Chabchoub</title>
      <link>https://dev.to/akremchabchoub</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akremchabchoub"/>
    <language>en</language>
    <item>
      <title>Top mistakes to avoid when integrating stripe</title>
      <dc:creator>Akrem Chabchoub</dc:creator>
      <pubDate>Fri, 24 May 2024 09:44:46 +0000</pubDate>
      <link>https://dev.to/softylines/top-mistakes-to-avoid-when-integrating-stripe-be8</link>
      <guid>https://dev.to/softylines/top-mistakes-to-avoid-when-integrating-stripe-be8</guid>
      <description>&lt;p&gt;Integrating Stripe into your application can streamline your payment processes, but it's essential to be aware of potential pitfalls and best practices. Here are some common mistakes and advice to help you navigate the integration smoothly.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Managing Webhooks Order
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyiwjxnkka9f9skx5yf2n.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyiwjxnkka9f9skx5yf2n.jpeg" alt="Order" width="800" height="600"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Webhooks&lt;/strong&gt; are a way for Stripe to communicate with your system by sending webhook events. However, webhook events do not guarantee order delivery. It’s essential to implement logic in your system to handle the order of events correctly. This prevents potential issues that can arise from processing out-of-order events.&lt;/p&gt;

&lt;p&gt;For example, when dealing with &lt;strong&gt;subscriptions&lt;/strong&gt;, Stripe might send you the update event before the create event, causing an error since you will try to update something in your system that does not exist yet. To handle this scenario, you can add logic in your &lt;strong&gt;update&lt;/strong&gt; event to check for the subscription's existence. If it's not present, retrieve it directly from Stripe, then update it.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. How To Reduce Latency When Working with Stripe's APIs
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1lx5aeluzeurc8nieh70.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1lx5aeluzeurc8nieh70.jpeg" alt="Latency" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
Latency issues can arise when dealing with Stripe’s APIs. For example, fetching customer &lt;strong&gt;invoices&lt;/strong&gt; from Stripe can be a slow operation. To mitigate this, consider storing or caching common data within your system. This approach reduces the need for repeated API calls and improves performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Invoice Links Expire After 30 Days
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frzf2bwols7kmdy40ouks.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frzf2bwols7kmdy40ouks.jpeg" alt="Expired" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
As you start storing invoices in your database, be aware that the PDF link of the invoice will expire after 30 days. To manage this, you can create a cron job to update the invoices or check the link's validity when retrieving invoices for the user. If the link has expired, get the updated link from Stripe and update it in your database.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.stripe.com/invoicing/hosted-invoice-page#:~:text=Invoice%20URLs%20expire%2030%20days,never%20longer%20than%20120%20days" rel="noopener noreferrer"&gt;Click for more info in Stripe docs&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Ensuring You Start with Live Mode In Production
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F18btmuqyrup3thog5bge.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F18btmuqyrup3thog5bge.jpeg" alt="Production" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
Stripe has two modes: live (production) and test (development). &lt;/p&gt;

&lt;p&gt;Sometimes, you might start your production app and begin accepting users even when the app isn't fully finished (especially for startups), thinking you can fix things later. However, when working with Stripe, you cannot switch all your test mode data to live mode (except for a few items). This will be a nightmare for you as a developer when you try to migrate the data. So, you should start your production with live mode from day one.&lt;/p&gt;

&lt;p&gt;Bonus: &lt;a href="https://docs.stripe.com/get-started/checklist/go-live" rel="noopener noreferrer"&gt;go-live check list by stripe&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Unsuccessful Payments Due to Account Freshness
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsbqgib0yg5sef7t0bxyr.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsbqgib0yg5sef7t0bxyr.jpeg" alt="Error" width="800" height="600"&gt;&lt;/a&gt;&lt;br&gt;
Sometimes, payments fail because the account is new, and your website hasn't yet been recognized by payment systems. This issue usually resolves itself over time as your site gains more credibility. Communicate this to your customers to manage their expectations.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Handling Changes in Payment Methods
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffac3xoz9gh4iged863yv.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffac3xoz9gh4iged863yv.jpeg" alt="Payment Methods" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
Payment networks can change payment method details (card number, expiration year, expiration month) at any time. Since you may store payment methods in your database, it’s crucial to stay updated by listening to the &lt;code&gt;automatically_updated_payment_method&lt;/code&gt; Stripe webhook. This webhook provides the latest data to keep your records up to date.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Managing Complex Plan Features
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa1qx1oau36wn6c8obb6l.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa1qx1oau36wn6c8obb6l.jpeg" alt="Complex Features" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
If your plans (offers) include complex features, add custom fields in your database rather than relying heavily on the plan’s metadata, which is limited. Custom fields provide greater flexibility and scalability for your application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Integrating Stripe into your application offers a streamlined payment process, but it comes with its own set of challenges. By understanding and addressing these common mistakes, you can ensure a smoother and more efficient integration. With these best practices, you can enhance your application's functionality and provide a better user experience.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>stripe</category>
      <category>bestpractises</category>
    </item>
    <item>
      <title>How to add auto-reloading in Golang projects with Nodemon: A Developer's Guide</title>
      <dc:creator>Akrem Chabchoub</dc:creator>
      <pubDate>Sun, 24 Mar 2024 04:24:17 +0000</pubDate>
      <link>https://dev.to/akremchabchoub/how-to-add-auto-reloading-in-go-projects-with-nodemon-a-developers-guide-2p7g</link>
      <guid>https://dev.to/akremchabchoub/how-to-add-auto-reloading-in-go-projects-with-nodemon-a-developers-guide-2p7g</guid>
      <description>&lt;p&gt;Are you a Go developer transitioning from the Node.js ecosystem? If so, you're probably familiar with nodemon, a popular tool for automatic live reloading during development. This article guides you through using nodemon to achieve a similar workflow in your Go projects.&lt;/p&gt;

&lt;h1&gt;
  
  
  Getting Started: Installing Node.js
&lt;/h1&gt;

&lt;p&gt;Before diving into the world of automatic reloading for Go, let's ensure you have Node.js installed. Node.js serves as the backbone for Nodemon's functionality. Head over to the official &lt;a href="https://nodejs.org/" rel="noopener noreferrer"&gt;Node.js website&lt;/a&gt; and follow the simple installation instructions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6wmucvmu8k37mxzn8nx5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6wmucvmu8k37mxzn8nx5.png" alt="Node.js official website" width="800" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Installing Nodemon Globally
&lt;/h1&gt;

&lt;p&gt;Once you've got Node.js up and running, the next step is to install Nodemon globally. Open your terminal and execute the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo npm install -g nodemon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nodemon, a utility that monitors for changes in your code and automatically restarts the server, will now be accessible across your system.&lt;/p&gt;

&lt;h1&gt;
  
  
  Implementing Nodemon in Your Go Project
&lt;/h1&gt;

&lt;p&gt;Now comes the exciting part – integrating Nodemon into your Go project. Let's break down the process step by step:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Choose Your Go File&lt;/strong&gt;: Identify the main Go file in your project. For the sake of this guide, we'll refer to it as main.go. However, feel free to adjust the filename according to your project's structure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Executing Nodemon&lt;/strong&gt;: In your terminal, execute the following command to leverage Nodemon:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nodemon --exec go run main.go --signal SIGTERM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: Remember, the &lt;code&gt;main.go&lt;/code&gt; file mentioned here is just an example. Feel free to substitute it with the appropriate filename based on your project setup.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In conclusion&lt;/strong&gt;, incorporating Nodemon into your Go projects revolutionizes the way you approach development. With its automatic reloading capabilities, you'll enjoy a smoother, more efficient coding experience from start to finish&lt;/p&gt;

</description>
      <category>livereload</category>
      <category>go</category>
      <category>nodemon</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How to pretty print json with golang ?</title>
      <dc:creator>Akrem Chabchoub</dc:creator>
      <pubDate>Sun, 13 Aug 2023 08:44:56 +0000</pubDate>
      <link>https://dev.to/akremchabchoub/how-to-pretty-print-json-with-golang--261d</link>
      <guid>https://dev.to/akremchabchoub/how-to-pretty-print-json-with-golang--261d</guid>
      <description>&lt;p&gt;As you know by default in Go you will use &lt;code&gt;fmt&lt;/code&gt; to print json data, this is ok but the data will be not beuatiful in the terminal, take this util function to print your json data in a pretty format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="c"&gt;// PrettyPrintData takes a single argument 'data' of any type (interface{}).&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;PrettyPrintData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="k"&gt;interface&lt;/span&gt;&lt;span class="p"&gt;{})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;// Convert data to pretty-printed JSON.&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;prettyOutput&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MarshalIndent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"  "&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prettyOutput&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c"&gt;// Handle error&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  This is how it will look in the terminal:
&lt;/h2&gt;

&lt;p&gt;Before:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"id":1,"name":"John","address":{"city":"New York","zipcode":"10001"},"friends":[{"name":"Mike"},{"name":"Anna"}]}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"John"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"address"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"city"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"New York"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"zipcode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"10001"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"friends"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Mike"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Anna"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope this will help you, and thanks for reading.&lt;/p&gt;

</description>
      <category>go</category>
      <category>json</category>
      <category>backend</category>
      <category>backenddevelopment</category>
    </item>
  </channel>
</rss>
