Introduction

This section describes the Dzwallet payment gateway API.


The Dzwallet API is simple to integrate into your company's software. Our API takes cURL requests, has well-formatted URLs, and produces JSON responses.

The API can be used in test mode without affecting your real data. The request is authenticated using the API key, which also establishes whether the payment is legitimate or not. For test mode just use the sandbox URL and In case of live mode use the live URL from section Initiate Payment.

Supported Currencies

The supported currencies by Dzwallet are given below.


Currency Currency Symbol
DZD DZD

Get The Api Key

How to obtain the api key is explained in this part.


To access your Dzwallet merchant account, please log in. In case you don't have an account, you can click here.

Now go to the Account > Settings > API Key from the merchant panel.

The api keys can be found there which is Public key and Secret key. Use these keys to initiate the API request. Every time you can generate new API key by clicking Generate Api Key button. Remember do not share these keys with anyone.

Initiate Payment

In this section, the procedure for initiating the payment is explained.


To begin the payment process, use the sample code provided, and pay close attention to the parameters. The API endpoints mentioned below will need to be used to make the request.

Live End Point: https://dzwallet.app/payment/initiate

Test End Point: https://dzwallet.app/test/payment/initiate

Request to the end point with the following parameters below.

Parameter Type Is Required Description
public_keystring (50)requiredYour Public API key
identifierstring (20)requiredIdentifier is basically for identify payment at your end
currencystring (4)requiredCurrency Code, Must be in Upper Case. e.g. DZD
amountdecimalrequiredPayment amount
detailsstring (100)requiredDetails of your payment or transaction
ipn_urlstringrequiredThe url of instant payment notification
success_urlstringrequiredPayment success redirect url
cancel_urlstringrequiredPayment cancel redirect url
site_namestringrequiredYour business site name
site_logostring/urlrequiredYour business site logo
checkout_themestringrequiredCheckout form theme dark/light. Default theme is light
Customer
customer[]arrayrequiredcustomer must be an array
customer.first_namestringrequiredCustomer's first name
customer.last_namestringrequiredCustomer's last name
customer.emailstringrequiredCustomer's valid email
customer.mobilestringrequiredCustomer's valid mobile
Shipping info
shipping_info[]arrayoptionalshipping_info must be an array
shipping_info.address_onestringoptionalCustomer's address one
shipping_info.address_twostringoptionalCustomer's address two
shipping_info.areastringoptionalShipping area of customer
shipping_info.citystringoptionalShipping city of customer
shipping_info.statestringoptionalShipping state
shipping_info.postcodestringoptionalShipping postcode
shipping_info.countrystringoptionalShipping country
Billing info
billing_info[]arrayoptionalbilling_info must be an array
billing_info.address_onestringoptionalCustomer's address one
billing_info.address_twostringoptionalCustomer's address two
billing_info.areastringoptionalBilling area of customer
billing_info.citystringoptionalBilling city of customer
billing_info.statestringoptionalBilling state
billing_info.postcodestringoptionalBilling postcode
billing_info.countrystringoptionalBilling country

Validate The Payment and IPN

This section describes the process to get your instant payment notification.


To initiate the payment follow the example code and be careful with the parameters. You will need to make request with these following API end points.

End Point: Your business application ipn url.

Request Method: POST

You will get following parameters below.

ParameterDescription
statusPayment success status.
identifierIdentifier is basically for identify payment at your end.
signatureA hash signature to verify your payment at your end.
dataData contains some basic information with charges, amount, currency, payment transaction id etc.
Initiate Payment
<?php
    $parameters = [
        'identifier' => 'DFU80XZIKS',
        'currency' => 'DZD',
        'amount' => 1000.00,
        'details' => 'Purchase description',
        'ipn_url' => 'http://example.com/ipn_url.php',
        'cancel_url' => 'http://example.com/cancel_url.php',
        'success_url' => 'http://example.com/success_url.php',
        'public_key' => 'your_public_key',
        'site_name' => 'your_site_name',
        'site_logo' => 'http://yoursite.com/logo.png',
        'checkout_theme' => 'light',
        'customer' => [
            'first_name' => 'John',
            'last_name' => 'Doe',
            'email' => 'john@example.com',
            'mobile' => '0555000000',
        ],
    ];

    $parameters = http_build_query($parameters);

    // Live end point
    $url = 'https://dzwallet.app/payment/initiate';

    // Test end point
    // $url = 'https://dzwallet.app/test/payment/initiate';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    curl_close($ch);
?>
Example Responses
// Error Response
{
    "status": "error",
    "message": ["Invalid api key"]
}

// Success Response
{
    "status": "success",
    "message": ["Payment initiated"],
    "redirect_url": "https://dzwallet.app/payment/checkout?payment_trx=..."
}
Validate The Payment and IPN
<?php
    $status = $_POST['status'];
    $signature = $_POST['signature'];
    $identifier = $_POST['identifier'];
    $data = $_POST['data'];

    // Generate your signature
    $customKey = $data['amount'] . $identifier;
    $secret = 'YOUR_SECRET_KEY';
    $mySignature = strtoupper(hash_hmac('sha256', $customKey, $secret));

    $myIdentifier = 'YOUR_GIVEN_IDENTIFIER';

    if ($status == "success" && $signature == $mySignature && $identifier == $myIdentifier) {
        // your operation logic
    }
?>