Skip to main content

Payment Gateways

UniPulse supports two payment providers: Stripe for global payments and Paymob for the Middle East & North Africa (MENA) region.


Provider Comparison

FeatureStripePaymob
RegionGlobalMENA (Egypt, Saudi Arabia, etc.)
Payment methodsCards, bank transfers, Apple Pay, Google PayCards, mobile wallets (Vodafone Cash, etc.)
SubscriptionsNative subscription managementManual via API
WebhooksComprehensive event systemPayment result callbacks
SDKstripe npm packageREST API

Payment Flow


Stripe Integration

API Endpoints

EndpointMethodDescription
/api/v1/payments/stripe/create-sessionPOSTCreate Stripe Checkout session
/api/v1/payments/stripe/webhookPOSTHandle Stripe webhooks
/api/v1/payments/stripe/portalPOSTCreate Stripe Customer Portal link

Webhook Events Handled

EventAction
invoice.paidMark subscription as active, create Transaction
customer.subscription.updatedUpdate plan, sync feature access
customer.subscription.deletedCancel subscription, downgrade to free
payment_intent.payment_failedMark subscription as past_due, notify user

Webhook Verification

// Verify Stripe webhook signature
const event = stripe.webhooks.constructEvent(
req.body,
req.headers['stripe-signature'],
process.env.STRIPE_WEBHOOK_SECRET
);

Paymob Integration

API Endpoints

EndpointMethodDescription
/api/v1/payments/paymob/create-sessionPOSTCreate Paymob payment
/api/v1/payments/paymob/callbackPOSTHandle Paymob payment callback

Payment Flow

StepAPI Call
1. AuthPOST /api/auth/tokens - Get auth token
2. OrderPOST /api/ecommerce/orders - Register order
3. Payment keyPOST /api/acceptance/payment_keys - Get payment key
4. RedirectRedirect user to Paymob iframe
5. CallbackPaymob calls webhook with result

Database Models

ModelPurposeKey Fields
SubscriptionActive workspace subscriptionworkspaceId, planId, status, provider, externalId, currentPeriodEnd
TransactionIndividual payment transactionsworkspaceId, amount, currency, provider, status, externalId
PaymentMethodStored payment methodsworkspaceId, provider, type, last4, expiryMonth, expiryYear
PlanAvailable subscription plansname, price, interval, features

Subscription Lifecycle


Environment Variables

VariableProviderRequired
STRIPE_SECRET_KEYStripeFor Stripe payments
STRIPE_WEBHOOK_SECRETStripeFor webhook verification
PAYMOB_API_KEYPaymobFor Paymob payments
Webhook Security

Always verify webhook signatures before processing. Never trust webhook payloads without signature verification -- they could be forged. Both Stripe and Paymob provide signature verification mechanisms.


Cross-Reference