<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged payhere</title>
<link>https://coderlegion.com/tag/payhere</link>
<description>Powered by Question2Answer</description>
<item>
<title>Building a Real-Time Payment Gateway Integration with PHP, PayHere, ngrok, and MySQL</title>
<link>https://coderlegion.com/26585/building-a-real-time-payment-gateway-integration-with-php-payhere-ngrok-and-mysql</link>
<description>&lt;p&gt;Recently, I built a complete &lt;strong&gt;real-time payment gateway integration&lt;/strong&gt; using &lt;strong&gt;PHP, PayHere Sandbox, ngrok, and MySQL&lt;/strong&gt; to simulate and test online payments in a local development environment.&lt;/p&gt;
&lt;p&gt;This project covered:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Secure PayHere checkout integration&lt;/li&gt;
&lt;li&gt;Real-time payment callback handling through ngrok&lt;/li&gt;
&lt;li&gt;Transaction logging and MySQL database storage&lt;/li&gt;
&lt;li&gt;Email notifications using PHPMailer&lt;/li&gt;
&lt;li&gt;PDF receipt generation using mPDF&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;One of the most interesting parts of the project was using &lt;strong&gt;ngrok to expose localhost securely&lt;/strong&gt;, allowing PayHere to communicate with local callback URLs such as &lt;code&gt;notify_url&lt;/code&gt;, &lt;code&gt;return_url&lt;/code&gt;, and &lt;code&gt;cancel_url&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The project structure was designed to keep the workflow clean and modular, with separate files for checkout processing, notifications, verification, configuration, and database handling.&lt;/p&gt;
&lt;p&gt;This implementation was a great hands-on experience in understanding how real-world payment systems work behind the scenes, from &lt;strong&gt;hash generation and callback verification&lt;/strong&gt; to &lt;strong&gt;preventing duplicate transactions and securely handling payment confirmations&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id=&quot;repository&quot;&gt;Repository&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/NithilaLD/Building-a-Real-Time-Payment-Gateway-Integration-with-PHP-PayHere-ngrok-and-MySQL/&quot;&gt;https://github.com/NithilaLD/Building-a-Real-Time-Payment-Gateway-Integration-with-PHP-PayHere-ngrok-and-MySQL/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The repository includes the complete project resources, including the full implementation guide in PDF format, source code files for the payment gateway integration, and database setup scripts required to configure and run the application locally.&lt;/p&gt;
&lt;h3 id=&quot;tech-stack&quot;&gt;Tech Stack&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;PHP | MySQL | PayHere Sandbox | ngrok | Composer | PHPMailer | mPDF&lt;/strong&gt;&lt;/p&gt;
&lt;h3 id=&quot;also-published-on&quot;&gt;Also Published On&lt;/h3&gt;
&lt;p&gt;This article is also available on the following platforms:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;LinkedIn:&lt;/strong&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.linkedin.com/pulse/building-real-time-payment-gateway-integration-php-liyanarachchi-yujgc/&quot;&gt;&lt;strong&gt;Read on LinkedIn&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medium:&lt;/strong&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://dulannithilaliyanarachchi.medium.com/building-a-real-time-payment-gateway-integration-with-php-payhere-ngrok-and-mysql-533c5e4a5720&quot;&gt;&lt;strong&gt;Read on Medium&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AWS:&lt;/strong&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://builder.aws.com/content/3ImAUjqYN0gmihHAxXEIlVJoHFn/building-a-real-time-payment-gateway-integration-with-php-payhere-ngrok-and-mysql&quot;&gt;&lt;strong&gt;Read on AWS&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;DEV Community:&lt;/strong&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://dev.to/dulannithilaliyanarachchi/building-a-real-time-payment-gateway-integration-with-php-payhere-ngrok-and-mysql-dnf&quot;&gt;&lt;strong&gt;Read on DEV Community&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/26585/building-a-real-time-payment-gateway-integration-with-php-payhere-ngrok-and-mysql</guid>
<pubDate>Wed, 09 Sep 2026 09:49:02 +0000</pubDate>
</item>
</channel>
</rss>