Payment Gateway PHP Source Code

In this article let’s see how implement Payment Gateway PHP Source Code project. Nowadays most of peoples are sell their products on online, so we need payment gateways for accept the amounts. Currently lot of gateways are available like CCAvenue, Payumoney, Razorpay, payubiz, Instamojo, citrus pay, paypal and more.

Recent days Razor Pay recommended by more developers because easy documentation & user friendly navigation. Another major reason accept international payments like US, UK etc.

Already we have clearly explained the procedure in one article which is integrated in Python language. But the steps are same in all technology. Therefore read here for the integration guides. Actually the steps are easy, we have to enter just merchant key & salt.

Here I have using framework, because payment gateway is not like easy process. Manually we need to setup some changes & implement code. So when we use CORE PHP, more difficulties to facing for handle the errors. That’s why most of developers are suggest some frameworks like Laravel, Codeigniter etc.

Payment Gateway PHP Steps to Follow

If you are beginner on this category once read the official documentation. After that you got some idea for build the code. The initial step is select one of the best payment gateway providers. For example in this project we have to select Razorpay software private limited.

I hope already you have download node on your system, to extract the dependency manager. So first create Laravel project via command prompt.

use Shipu\Aamarpay\Aamarpay;

$config = [
    'store_id' => 'Your store id',
    'signature_key' => 'Your signature key',
    'sandbox' => true,
    'redirect_url' => [
        'success' => [
            'route' => 'payment.success'
        'cancel' => [
            'route' => 'payment.cancel' 

$payment = new Aamarpay($config);

Above code is explained the mandatory field of modules which is connected to on the database. Then only we able to communicate with database system. Otherwise the exact data not transfer & on back-end communication.


Usage means which is mostly used for back-end process like how data accessed & stored on server side. In this project I have using MySQL database. It was mostly recommended language for 95 percentage peoples of developers.

payment gateway PHP source code
  1. Customer Name
  2. Email-id / Phone Number
  3. Card Details
  4. Currency
  5. Bank Details
  6. Confirmation Receipt.
  7. Money Transfer Status
  8. Check Balance
  9. Offers (optional)

Passing URL for Payment

To pass the URL for payment gateway server who are totally manage the back-end process. Which means get full permission for transfer & receive the amount from customers.

use \Shipu\Aamarpay\Aamarpay;


$payment = new Aamarpay(config('aamarpay'));
return $payment->customer([
    'cus_name'  => 'Shipu Ahamed', // Customer name
    'cus_phone' => '01616022669' // Customer Phone
    'cus_email' => '', // Customer email


return $payment->customer([
    'cus_name'  => 'Shipu Ahamed', // Customer name
    'cus_phone' => '9854345483' // Customer Phone
    'cus_email' => '', // Customer email

For the demo purpose, in the above section provide unverified details. But in the live process, we must give the validated information. After that only the particular customers able to send and receive the payments. These days most of peoples make online payments like Payumoney, CCAvenue, Net Banking, Phonepe and more applications are available.

Payment Gateway Process

Generally when we make online payments, there are three possibilities when our transaction will be failed. That was,

  1. Success Message (Amount will be credited/Debited Successfully)
  2. Failed (Server Busy)
  3. Canceled (It was raised by client itself)
Route::post('payment/success', 'YourMakePaymentsController@paymentSuccess')->name('payment.success');
Route::post('payment/failed', 'YourMakePaymentsController@paymentFailed')->name('payment.failed');
Route::post('payment/cancel', 'YourMakePaymentsController@paymentCancel')->name('payment.cancel');

Payment Gateway PHP

Above all code helps to build this project. Moreover surely issues are raised when develop on our own risk. Because in some places we make connection process. So through the online documentation helps, we easily do it on our end. In below get Payment Gateway PHP Source code in free of cost.

Leave a Reply