Skip to main content

Overview

Beyond the primary payment gateways, Ecom supports numerous regional and specialized payment processors. Each gateway is optimized for specific regions and use cases.

Available Gateways

Paystack (Africa)

Popular payment gateway for African markets, especially Nigeria, Ghana, and South Africa.

Configuration

.env
PAYSTACK_PUBLIC_KEY=pk_...
PAYSTACK_SECRET_KEY=sk_...
PAYSTACK_CURRENCY_CODE=NGN

Controller Location

app/Http/Controllers/Payment/PaystackController.php

Implementation Highlights

app/Http/Controllers/Payment/PaystackController.php
public function pay(Request $request)
{
    $post_data = array();
    $post_data['payment_type'] = Session::get('payment_type');

    if (Session::get('payment_type') == 'cart_payment') {
        $combined_order = CombinedOrder::findOrFail(Session::get('combined_order_id'));
        $user = Auth::user();
        
        $request->email = $user->email;
        $request->amount = round($combined_order->grand_total * 100);
        $request->currency = env('PAYSTACK_CURRENCY_CODE', 'NGN');
        $request->metadata = json_encode($array);
        $request->reference = Paystack::genTranxRef();
        
        return Paystack::getAuthorizationUrl()->redirectNow();
    }
}

Supported Currencies

  • NGN (Nigerian Naira)
  • GHS (Ghanaian Cedi)
  • ZAR (South African Rand)
  • USD (US Dollar)

Dependencies

composer.json
"unicodeveloper/laravel-paystack": "^1.0"

Instamojo (India)

Indian payment gateway supporting UPI, cards, wallets, and net banking.

Configuration

.env
IM_API_KEY=...
IM_AUTH_TOKEN=...

Controller Location

app/Http/Controllers/Payment/InstamojoController.php

Implementation Highlights

app/Http/Controllers/Payment/InstamojoController.php
public function pay()
{
    if (BusinessSetting::where('type', 'instamojo_sandbox')->first()->value == 1) {
        $endPoint = 'https://test.instamojo.com/api/1.1/';
    } else {
        $endPoint = 'https://www.instamojo.com/api/1.1/';
    }

    $api = new \Instamojo\Instamojo(
        env('IM_API_KEY'),
        env('IM_AUTH_TOKEN'),
        $endPoint
    );

    if (Session::get('payment_type') == 'cart_payment') {
        $combined_order = CombinedOrder::findOrFail(Session::get('combined_order_id'));
        
        $response = $api->paymentRequestCreate(array(
            "purpose" => ucfirst(str_replace('_', ' ', Session::get('payment_type'))),
            "amount" => round($combined_order->grand_total),
            "send_email" => false,
            "email" => Auth::user()->email,
            "phone" => Auth::user()->phone,
            "redirect_url" => url('instamojo/payment/pay-success')
        ));
        
        return redirect($response['longurl']);
    }
}

Phone Validation

Instamojo requires valid Indian phone numbers:
if (preg_match_all('/^(?:(?:\+|0{0,2})91(\s*[\ -]\s*)?|[0]?)?[789]\d{9}|(\d[ -]?)\{10}\d$/im', Auth::user()->phone)) {
    // Process payment
} else {
    flash(translate('Please add phone number to your profile'))->warning();
    return redirect()->route('profile');
}

Dependencies

composer.json
"instamojo/instamojo-php": "^0.4.0"

Authorize.Net (USA)

Established payment gateway for North American markets.

Configuration

.env
AUTHORIZE_NET_LOGIN_ID=...
AUTHORIZE_NET_TRANSACTION_KEY=...
AUTHORIZE_NET_SANDBOX=true

Controller Location

app/Http/Controllers/Payment/AuthorizenetController.php

Dependencies

composer.json
"authorizenet/authorizenet": "^2.0"

Iyzico (Turkey)

Turkish payment gateway supporting local payment methods.

Controller Location

app/Http/Controllers/Payment/IyzicoController.php

Dependencies

composer.json
"iyzico/iyzipay-php": "^2.0"

Mercadopago (Latin America)

Leading payment platform for Latin American markets.

Controller Location

app/Http/Controllers/Payment/MercadopagoController.php

Dependencies

composer.json
"mercadopago/dx-php": "^2.5"

Nagad (Bangladesh)

Bangladeshi mobile financial service.

Controller Location

app/Http/Controllers/Payment/NagadController.php

bKash (Bangladesh)

Mobile banking service in Bangladesh.

Controller Location

app/Http/Controllers/Payment/BkashController.php

Paytm (India)

Indian digital wallet and payment gateway.

Configuration

.env
PAYTM_ENVIRONMENT=production
PAYTM_MERCHANT_ID=...
PAYTM_MERCHANT_KEY=...
PAYTM_MERCHANT_WEBSITE=...
PAYTM_CHANNEL=WEB
PAYTM_INDUSTRY_TYPE=Retail

Dependencies

composer.json
"anandsiddharth/laravel-paytm-wallet": "^2.0"

Flutterwave (Africa)

African payment gateway supporting multiple countries.

Controller Location

app/Http/Controllers/Payment/FlutterwaveController.php

Dependencies

composer.json
"kingflamez/laravelrave": "dev-master"

Payhere (Sri Lanka)

Sri Lankan payment gateway.

Controller Location

app/Http/Controllers/Payment/PayhereController.php

Ngenius (Middle East)

Payment gateway for Middle Eastern markets.

Controller Location

app/Http/Controllers/Payment/NgeniusController.php

Payku (Chile)

Chilean payment gateway.

Controller Location

app/Http/Controllers/Payment/PaykuController.php

Dependencies

composer.json
"sebacarrasco93/laravel-payku": "^1.0"

MyFatoorah (Middle East)

Payment gateway for Kuwait and Middle East.

Dependencies

composer.json
"myfatoorah/laravel-package": "^2.1"

Voguepay (Africa)

African payment gateway.

Controller Location

app/Http/Controllers/Payment/VoguepayController.php

Aamarpay (Bangladesh)

Bangladeshi payment aggregator.

Controller Location

app/Http/Controllers/Payment/AamarpayController.php

Common Payment Architecture

All payment gateways follow this pattern:

Payment Types Supported

if (Session::has('payment_type')) {
    switch (Session::get('payment_type')) {
        case 'cart_payment':
            $combined_order = CombinedOrder::findOrFail(Session::get('combined_order_id'));
            $amount = $combined_order->grand_total;
            break;
            
        case 'wallet_payment':
            $amount = Session::get('payment_data')['amount'];
            break;
            
        case 'customer_package_payment':
            $customer_package = CustomerPackage::findOrFail(Session::get('payment_data')['customer_package_id']);
            $amount = $customer_package->amount;
            break;
            
        case 'seller_package_payment':
            $seller_package = SellerPackage::findOrFail(Session::get('payment_data')['seller_package_id']);
            $amount = $seller_package->amount;
            break;
    }
}

Payment Completion

if (Session::has('payment_type')) {
    if (Session::get('payment_type') == 'cart_payment') {
        return (new CheckoutController)->checkout_done(Session::get('combined_order_id'), $payment_details);
    } elseif (Session::get('payment_type') == 'wallet_payment') {
        return (new WalletController)->wallet_payment_done(Session::get('payment_data'), $payment_details);
    } elseif (Session::get('payment_type') == 'customer_package_payment') {
        return (new CustomerPackageController)->purchase_payment_done(Session::get('payment_data'), $payment_details);
    } elseif (Session::get('payment_type') == 'seller_package_payment') {
        return (new SellerPackageController)->purchase_payment_done(Session::get('payment_data'), $payment_details);
    }
}

Cash on Delivery

Ecom also supports Cash on Delivery (COD):

Controller Location

app/Http/Controllers/Payment/CashOnDeliveryController.php
COD requires no external gateway integration and can be enabled directly from the admin panel.

Wallet Payment

Internal wallet system for stored balance:

Controller Location

app/Http/Controllers/Payment/WalletController.php
Customers can recharge wallet using any enabled payment gateway and use wallet balance for purchases.

Gateway Selection Guide

By Region

RegionRecommended Gateways
GlobalStripe, PayPal
IndiaRazorpay, Paytm, Instamojo
BangladeshSSLCommerz, bKash, Nagad, Aamarpay
AfricaPaystack, Flutterwave, Voguepay
Middle EastNgenius, MyFatoorah, Payhere
Latin AmericaMercadopago
TurkeyIyzico
USA/CanadaStripe, PayPal, Authorize.Net
ChilePayku

By Use Case

  • International Business: Stripe, PayPal
  • Regional Focus: Choose local gateway for best conversion
  • Mobile Payments: bKash, Nagad, Paytm, Razorpay (UPI)
  • Low Transaction Fees: Compare rates for your region
  • Quick Setup: PayPal, Stripe

Installation Steps

For any payment gateway:
1

Install Dependencies

composer require vendor/package-name
2

Get API Credentials

Register with the payment provider and obtain API keys
3

Configure Environment

Add credentials to .env file
4

Enable in Admin Panel

Activate the gateway in Setup & ConfigurationsPayment Methods
5

Test Integration

Use sandbox/test mode to verify payment flow
6

Go Live

Switch to production credentials after testing

Security Considerations

Universal Security Best Practices
  • Never commit API keys to version control
  • Use environment variables for all credentials
  • Implement HTTPS for all payment pages
  • Validate payment amounts server-side
  • Enable webhook signature verification
  • Log all payment transactions
  • Set up fraud detection where available
  • Use separate credentials for dev/staging/production
  • Regularly audit payment logs
  • Implement rate limiting on payment endpoints

Troubleshooting Common Issues

Solution:
  • Verify gateway is enabled in admin panel
  • Check API credentials are correct in .env
  • Ensure required Composer packages are installed
  • Clear application cache: php artisan cache:clear
Solution:
  • Verify system default currency matches gateway supported currencies
  • Check currency code format (USD vs usd)
  • Some gateways only support specific currencies
Solution:
  • Ensure URLs are publicly accessible
  • Check HTTPS is enabled for production
  • Verify routes are registered in routes/web.php
  • Check web server configuration (nginx/Apache)
Solution:
  • Some gateways need cents: $amount * 100
  • Others need decimal: number_format($amount, 2, '.', '')
  • Check specific gateway documentation

Testing Recommendations

For each gateway:
  1. Test all payment types: cart, wallet, packages
  2. Test success flow: Complete payment successfully
  3. Test failure flow: Cancel or decline payment
  4. Test amount calculation: Verify correct amounts charged
  5. Test currency handling: Ensure proper currency conversion
  6. Test user authentication: Verify user session maintained
  7. Test order creation: Confirm orders created correctly

Payment Overview

Learn about payment gateway architecture

Stripe Integration

Primary international gateway

Razorpay Integration

Primary Indian gateway

SSLCommerz Integration

Primary Bangladesh gateway

Build docs developers (and LLMs) love