Labsco
zakblacki logo

Satim Payment Gateway Integration

15

from zakblacki

Integrate with Algeria's SATIM payment gateway to process CIB and Edhahabia card payments.

🔥🔥🔥✓ VerifiedAccount requiredAdvanced setup

Obviously you should have already an account created and working to get credentials from here : https://cibweb.dz/fr/login

Satim Payment Gateway Integration

A Model Context Protocol (MCP) server for integrating with the SATIM payment gateway system in Algeria. The server provides a structured interface for processing CIB/Edhahabia card payments through the SATIM-ePAY platform. This package enables AI assistants like Cursor, Claude, and Copilot to directly access your account data through a standardized interface.

<a href="https://glama.ai/mcp/servers/@zakblacki/Satim-Payment-Gateway-Integration"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@zakblacki/Satim-Payment-Gateway-Integration/badge" alt="Satim Payment Gateway Integration MCP server" /> </a>

Table of Contents

  1. Installation
  2. Configuration
  3. Payment Flow
  4. Tools
  5. Testing
  6. Integration Requirements
  7. Error Handling
  8. Examples
  9. Security Considerations

Payment Flow

The complete payment process follows these steps:

1. Order Registration

Copy & paste — that's it
const registrationResult = await mcp.callTool("register_order", {
  orderNumber: "ORDER_001_2024",
  amountInDA: 1500.50,  // Amount in Algerian Dinars
  returnUrl: "https://yoursite.com/payment/success",
  failUrl: "https://yoursite.com/payment/failure",
  force_terminal_id: "E005005097",
  udf1: "merchant_ref_123",
  language: "FR"
});

// Response includes orderId and formUrl
// Redirect customer to formUrl for payment

2. Customer Payment

  • Customer fills CIB/Edhahabia card details on SATIM form
  • Customer is redirected back to your returnUrl/failUrl

3. Order Confirmation

Copy & paste — that's it
const confirmResult = await mcp.callTool("confirm_order", {
  orderId: "received_order_id",
  language: "FR"
});

// Validate the response
const validation = await mcp.callTool("validate_payment_response", {
  response: confirmResult
});

4. Display Results

Based on validation results, display appropriate messages to customers.

Tools

configure_credentials

Configure SATIM gateway credentials.

Parameters:

  • userName (string, required): Merchant login
  • password (string, required): Merchant password

register_order

Register a new payment order.

Parameters:

  • orderNumber (string, required): Unique order identifier
  • amountInDA (number, required): Amount in Algerian Dinars (min: 50 DA)
  • returnUrl (string, required): Success redirect URL
  • failUrl (string, optional): Failure redirect URL
  • force_terminal_id (string, required): Bank-assigned terminal ID
  • udf1 (string, required): SATIM-specific parameter
  • currency (string, optional): Currency code (default: "012" for DZD)
  • language (string, optional): Interface language ("AR", "FR", "EN")
  • description (string, optional): Order description
  • udf2-udf5 (string, optional): Additional parameters

Response:

Copy & paste — that's it
{
  "orderId": "123456789AZERTYUIOPL",
  "formUrl": "https://test.satim.dz/payment/merchants/merchant1/payment_fr.html?mdOrder=123456789AZERTYUIOPL"
}

confirm_order

Confirm order status after payment attempt.

Parameters:

  • orderId (string, required): Order ID from registration
  • language (string, optional): Response language

Response:

Copy & paste — that's it
{
  "orderNumber": "ORDER_001_2024",
  "actionCode": 0,
  "actionCodeDescription": "Votre paiement a été accepté",
  "amount": 150050,
  "errorCode": "0",
  "orderStatus": 2,
  "approvalCode": "303004",
  "params": {
    "respCode": "00",
    "respCode_desc": "Votre paiement a été accepté"
  }
}

refund_order

Process a refund for a completed order.

Parameters:

  • orderId (string, required): Order ID to refund
  • amountInDA (number, required): Refund amount in DA
  • currency (string, optional): Currency code
  • language (string, optional): Response language

Response:

Copy & paste — that's it
{
  "errorCode": 0
}

validate_payment_response

Validate and interpret payment response.

Parameters:

  • response (object, required): Order confirmation response

Response:

Copy & paste — that's it
{
  "status": "ACCEPTED",
  "displayMessage": "Votre paiement a été accepté",
  "shouldShowContactInfo": false,
  "contactNumber": "3020 3020"
}

Testing

Method 1: Quick Test

Create a simple test file test-simple.js:

Copy & paste — that's it
import { spawn } from 'child_process';

// Start the MCP server
const server = spawn('npx', ['tsx', 'satim-mcp-server.ts'], {
  stdio: ['pipe', 'pipe', 'inherit']
});

console.log('SATIM MCP Server started for testing');

// Let it run for a few seconds then exit
setTimeout(() => {
  server.kill();
  console.log('Test completed');
}, 5000);

Run with:

Copy & paste — that's it
node test-simple.js

Method 2: Full Integration Test

Create test-client.ts following the example in the documentation, then run:

Copy & paste — that's it
npm run test

Method 3: HTTP Wrapper for API Testing

Use the HTTP wrapper example provided in the documentation to create REST API endpoints for easier testing with tools like Postman or curl.

Error Handling

Order Registration Errors

  • Invalid credentials
  • Duplicate order number
  • Invalid amount (< 50 DA)
  • Missing required parameters

Confirmation Errors

Error CodeDescription
0Successfully confirmed
1Empty order ID
2Already confirmed
3Access denied
5Access denied
6Unknown order
7System error

Refund Errors

Error CodeDescription
0No system error
5Password change required / Empty order ID
6Wrong order number
7Payment state error / Amount error / System error

Examples

Complete Payment Flow

Copy & paste — that's it
// 1. Configure credentials
await mcp.callTool("configure_credentials", {
  userName: "test_merchant",
  password: "test_password"
});

// 2. Register order
const order = await mcp.callTool("register_order", {
  orderNumber: `ORDER_${Date.now()}`,
  amountInDA: 250.75,
  returnUrl: "https://mystore.dz/payment/success",
  failUrl: "https://mystore.dz/payment/failure",
  force_terminal_id: "E005005097",
  udf1: "customer_ref_456",
  language: "FR",
  description: "Achat produit électronique"
});

// 3. Redirect customer to order.formUrl
// Customer completes payment and returns

// 4. Confirm payment
const confirmation = await mcp.callTool("confirm_order", {
  orderId: order.orderId,
  language: "FR"
});

// 5. Validate response
const validation = await mcp.callTool("validate_payment_response", {
  response: confirmation
});

// 6. Handle result
if (validation.status === "ACCEPTED") {
  // Process successful payment
  console.log("Payment successful:", validation.displayMessage);
} else if (validation.status === "REJECTED") {
  // Handle rejection
  console.log("Payment rejected");
} else {
  // Handle error
  console.log("Payment error:", validation.displayMessage);
}

Processing Refunds

Copy & paste — that's it
// Full refund
const refund = await mcp.callTool("refund_order", {
  orderId: "123456789AZERTYUIOPL",
  amountInDA: 250.75,  // Full original amount
  language: "FR"
});

// Partial refund
const partialRefund = await mcp.callTool("refund_order", {
  orderId: "123456789AZERTYUIOPL",
  amountInDA: 100.00,  // Partial amount
  language: "FR"
});

Security Considerations

Credentials Management

  • Store credentials securely (environment variables, key vault)
  • Use HTTPS for all communications
  • Implement proper authentication for your API endpoints

Order Number Security

  • Use unique, non-sequential order numbers
  • Include timestamp or random elements
  • Validate order ownership before confirmation

Data Validation

  • Always validate amounts on server side
  • Verify order status before processing confirmations
  • Implement idempotency for refund operations

Logging and Monitoring

  • Log all payment transactions
  • Monitor for suspicious activities
  • Implement rate limiting for API calls

Support and Contact

  • SATIM Support: 3020 3020 (toll-free)
  • Technical Issues: Contact your integration specialist
  • Documentation: Refer to official SATIM integration guides

This MCP server implementation follows SATIM's official API specifications and includes all required integration points for Algerian e-commerce platforms.