API Documentation

Build payments
in minutes, not months

A clean REST API, official SDKs, sandbox testing, real-time webhooks, and comprehensive documentation. Everything you need to integrate DWS into any application.

Simple. Powerful. Secure.

The DWS REST API follows industry-standard conventions. If you've used Stripe or Adyen, you'll feel at home. HTTP verbs, JSON request/response, predictable URLs, and detailed error messages.

RESTful API

Standard HTTP verbs, JSON payloads, and predictable resource-oriented URLs.

API Key Auth

Secure API key authentication. Use test keys in sandbox, live keys in production.

Real-time Webhooks

Receive instant notifications for payment events, refunds, and status changes.

Sandbox Environment

Full testing environment with test card numbers and simulated payment flows.

Base URL
https://api.digital-wallet-services.com/v1
Create Payment
use DWS\Client;

$client = new Client([
  'api_key' => 'sk_live_xxxxxxxxxxxxxxxx',
]);

$payment = $client->createPayment([
  'amount'      => 100000,
  'currency'    => 'MAD',
  'description' => 'Order #1234',
  'customer'    => [
    'email'  => 'customer@example.com',
    'name'   => 'Mohamed Amine',
  ],
  'return_url'  => 'https://yoursite.ma/success',
]);

header('Location: ' . $payment->checkout_url);

Official SDKs

Idiomatic libraries for your preferred language. Just install and start building.

🐘
PHP
PHP 8.1+
v1.4.2
$ composer require dws/dws-php
JavaScript
Node.js 18+ / Browser
v2.1.0
$ npm install @dws/dws-js
🐍
Python
Python 3.9+
v1.2.1
$ pip install dws-python

Real-time Webhooks

DWS sends instant HTTP POST notifications to your endpoint for every payment event. No polling required - your system reacts in real time.

payment.succeeded Payment completed successfully
payment.failed Payment attempt failed
payment.refunded Refund processed
subscription.created New subscription started
subscription.renewed Subscription auto-renewed
wallet.credited Wallet balance increased
Webhook Handler (PHP)
$payload = json_decode(
  file_get_contents('php://input'), true
);

$client->webhooks->verify(
  $payload,
  $_SERVER['HTTP_DWS_SIGNATURE'],
  'whsec_xxxxxxxxxxxx'
);

switch ($payload['event']) {
  case 'payment.succeeded':
    fulfillOrder($payload['data']);
    break;
  case 'payment.failed':
    notifyCustomer($payload['data']);
    break;
}

http_response_code(200);
Sandbox Environment

Test without risk

The DWS sandbox is a full replica of the production environment - with test card numbers, simulated payment flows, and real-time webhook delivery. Test everything before going live.

Full API parity with production
Test card numbers for all scenarios
Simulated 3DS2 authentication flows
Real-time webhook delivery
Dashboard access with test data
No real money - completely safe
Test Card Numbers
4242 4242 4242 4242
Successful payment
4000 0000 0000 0002
Payment declined
4000 0025 0000 3155
3DS2 required
4000 0000 0000 9995
Insufficient funds

Ready to integrate?

Get your API keys, explore the sandbox, and build your integration. Our developer team is here to help.