Skip to main content

Supported Payment Gateways

Ecom supports a wide range of payment gateways to accommodate customers worldwide. All payment integrations follow a consistent pattern and support multiple payment types:
  • Cart payment
  • Wallet recharge
  • Customer package purchase
  • Seller package purchase

Available Gateways

Stripe

International credit/debit card processing

PayPal

Global payment processing platform

Razorpay

Indian payment gateway

SSLCommerz

Bangladesh payment gateway

Paystack

African payment gateway

Other Gateways

Instamojo, Authorize.net, and more

Payment Flow Architecture

All payment controllers in Ecom follow this standardized flow:

1. Payment Initiation

Payments are initiated from the checkout process with session data:
// Session stores payment context
Session::put('payment_type', 'cart_payment');
Session::put('combined_order_id', $order->id);

2. Payment Processing

Each gateway controller implements these key methods:
  • pay() - Initiates payment with gateway
  • success() - Handles successful payment callback
  • cancel()/fail() - Handles payment cancellation/failure

3. Payment Completion

After successful payment, the appropriate controller method is called:
if ($payment_type == 'cart_payment') {
    return (new CheckoutController)->checkout_done($order_id, $payment_details);
} elseif ($payment_type == 'wallet_payment') {
    return (new WalletController)->wallet_payment_done($payment_data, $payment_details);
}

Common Environment Variables

Most payment gateways require API credentials in .env:
# Gateway credentials
GATEWAY_API_KEY=your_api_key
GATEWAY_SECRET_KEY=your_secret_key

# Sandbox/Production mode
GATEWAY_SANDBOX=true

# Currency settings
SYSTEM_DEFAULT_CURRENCY=1

Payment Types Supported

Cart Payment

Standard checkout payment for product orders:
if (Session::get('payment_type') == 'cart_payment') {
    $combined_order = CombinedOrder::findOrFail(Session::get('combined_order_id'));
    $amount = $combined_order->grand_total;
}

Wallet Payment

Customer wallet recharge:
if (Session::get('payment_type') == 'wallet_payment') {
    $amount = Session::get('payment_data')['amount'];
}

Package Payments

Customer or seller package purchases:
if (Session::get('payment_type') == 'customer_package_payment') {
    $customer_package = CustomerPackage::findOrFail(Session::get('payment_data')['customer_package_id']);
    $amount = $customer_package->amount;
}

Security Best Practices

Never commit API keys to version controlAlways use environment variables for sensitive credentials:
  • Keep .env out of git (add to .gitignore)
  • Use different credentials for development/production
  • Rotate API keys regularly
  • Enable webhook signature verification where available

Testing Payment Integrations

Sandbox Mode

Most gateways provide sandbox environments:
if (get_setting('paypal_sandbox') == 1) {
    $environment = new SandboxEnvironment($clientId, $clientSecret);
} else {
    $environment = new ProductionEnvironment($clientId, $clientSecret);
}

Test Cards

Use gateway-provided test cards in sandbox mode:
  • Stripe: 4242 4242 4242 4242
  • Razorpay: Any valid card number in test mode
  • PayPal: Use sandbox account credentials

Gateway Comparison

GatewayRegionsCurrenciesSettlement TimeFees
StripeGlobal135+2-7 days2.9% + 30¢
PayPalGlobal25+1-3 days2.9% + 30¢
RazorpayIndiaINR2-3 days2%
SSLCommerzBangladeshBDT2-3 days2-3%
PaystackAfricaNGN, GHS, ZAR1-3 days1.5-2%

Next Steps

Configure Stripe

Set up Stripe payment integration

Configure PayPal

Set up PayPal payment integration

Configure Razorpay

Set up Razorpay for Indian payments

Other Gateways

Explore additional payment options

Build docs developers (and LLMs) love