Skip to main content

MB WAY (Portugal)

tip

Accepting this payment channel requires an additional agreement with the acquiring agent designated by dpay.pl.

MB WAY is a popular mobile payment method in Portugal. The customer authorizes the payment directly in the MB WAY app on their phone by providing only their phone number.

How it works

POST/api/v1_0/payments/registerComplete payment registration contract: parameters, checksum, and error codes.Full contract in the API Reference

Endpoint

POST https://api-payments.dpay.pl/api/v1_0/payments/register
Content-Type: application/json
Rate limits

The payment registration endpoint supports up to 120 requests per minute.

Request parameters

FieldTypeRequiredDescription
transactionTypestringYes"mb_way_direct"
servicestringYesService name from the dashboard
valuestringYesAmount in EUR
currency_codestringYes"EUR"
channelstringYes"373"
emailstringYes (with channel)Customer's email address
client_namestringYes (with channel)Customer's first name
client_surnamestringYes (with channel)Customer's last name
accept_tosbooleanYes (with channel)Confirmation that the customer accepts the terms and conditions
phone_numberstringYesPhone number in +351XXXXXXXXX format
url_successstringYesURL after a successful payment
url_failstringYesURL after a failed payment
url_ipnstringYesURL for IPN notifications
checksumstringYesSHA-256 checksum
device_infoobjectYesCustomer device information (all fields listed below)
Fields accompanying channel

Providing the channel field also requires email, client_name, client_surname, and accept_tos. If any of them is missing, the request fails validation (HTTP 422).

Phone number format

Use the standard international phone number format:

+351XXXXXXXXX

Where:

  • +351 - Portugal's country code
  • XXXXXXXXX - 9-digit phone number

Example: +351912345678

device_info object

For mb_way_direct transactions, all fields below are required:

{
"browserAcceptHeader": "text/html,application/xhtml+xml",
"browserJavaEnabled": "false",
"browserLanguage": "pt-PT",
"browserColorDepth": 24,
"browserScreenHeight": 1080,
"browserScreenWidth": 1920,
"browserTZ": 0,
"browserUserAgent": "Mozilla/5.0 ...",
"systemFamily": "Windows",
"deviceID": "device-uuid-1234",
"applicationName": "Chrome",
"geoLocalization": "38.7223,-9.1393"
}
device_info field types

The browserJavaEnabled field must be the string "true" or "false" (not a boolean). The browserColorDepth, browserScreenHeight, browserScreenWidth, and browserTZ fields are integers. If any field in the device_info object is missing, the request fails validation (HTTP 422).

Request example

cURL

curl -X POST https://api-payments.dpay.pl/api/v1_0/payments/register \
-H "Content-Type: application/json" \
-d '{
"transactionType": "mb_way_direct",
"service": "abc123",
"value": "14.99",
"currency_code": "EUR",
"channel": "373",
"email": "customer@example.com",
"client_name": "Joao",
"client_surname": "Silva",
"accept_tos": true,
"phone_number": "+351912345678",
"url_success": "https://myshop.example/success",
"url_fail": "https://myshop.example/failure",
"url_ipn": "https://myshop.example/api/ipn",
"checksum": "e3b0c44298fc1c149afb...",
"device_info": {
"browserAcceptHeader": "text/html,application/xhtml+xml",
"browserJavaEnabled": "false",
"browserLanguage": "pt-PT",
"browserColorDepth": 24,
"browserScreenHeight": 1080,
"browserScreenWidth": 1920,
"browserTZ": 0,
"browserUserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
"systemFamily": "Windows",
"deviceID": "device-uuid-1234",
"applicationName": "Chrome",
"geoLocalization": "38.7223,-9.1393"
}
}'

PHP

<?php
$service = getenv('DPAY_SERVICE');
$secretHash = getenv('DPAY_SECRET_HASH');

$value = '14.99';
$urlSuccess = 'https://myshop.example/success';
$urlFail = 'https://myshop.example/failure';
$urlIpn = 'https://myshop.example/api/ipn';

$checksum = hash('sha256',
$service . '|' . $secretHash . '|' . $value . '|' .
$urlSuccess . '|' . $urlFail . '|' . $urlIpn
);

$payload = json_encode([
'transactionType' => 'mb_way_direct',
'service' => $service,
'value' => $value,
'currency_code' => 'EUR',
'channel' => '373',
'email' => $_POST['email'],
'client_name' => $_POST['client_name'],
'client_surname' => $_POST['client_surname'],
'accept_tos' => true,
'phone_number' => '+351' . $_POST['phone_number'],
'url_success' => $urlSuccess,
'url_fail' => $urlFail,
'url_ipn' => $urlIpn,
'checksum' => $checksum,
'device_info' => [
'browserAcceptHeader' => 'text/html,application/xhtml+xml',
'browserJavaEnabled' => 'false',
'browserLanguage' => 'pt-PT',
'browserColorDepth' => 24,
'browserScreenHeight' => 1080,
'browserScreenWidth' => 1920,
'browserTZ' => 0,
'browserUserAgent' => $_SERVER['HTTP_USER_AGENT'],
'systemFamily' => 'Windows',
'deviceID' => $_POST['device_id'],
'applicationName' => 'Chrome',
'geoLocalization' => $_POST['geo'],
],
]);

$ch = curl_init('https://api-payments.dpay.pl/api/v1_0/payments/register');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_RETURNTRANSFER => true,
]);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);

API response

Success - awaiting confirmation

{
"error": false,
"msg": "Internal processing",
"status": true,
"transactionId": "abc-def-123-456"
}

The status field is a boolean (true/false). The Internal processing response means the transaction has been accepted and the customer must now confirm the payment in the MB WAY app. You will receive the payment result via IPN.

Registration error (HTTP 400)

Errors detected during registration, such as a missing phone number, use the following response format:

{
"status": "failed",
"message": "Phone number is required for MB Way Direct transactions.",
"errors": []
}

Payment rejection

When the provider rejects a payment, the transaction is cancelled and the error code and description are returned in additionalInfo:

{
"error": true,
"msg": "Transaction canceled",
"status": false,
"transactionId": "abc-def-123-456",
"additionalInfo": {
"error": "E0506",
"error_description": "Alias does not exist"
}
}

Form example

<form id="mbway-form">
<label for="phone">Phone number (Portugal)</label>
<div style="display: flex; align-items: center;">
<span>+351</span>
<input
type="tel"
id="phone"
name="phone_number"
maxlength="9"
pattern="[0-9]{9}"
placeholder="912345678"
required
/>
</div>
<button type="submit">Pay with MB WAY</button>
</form>

<script>
document.getElementById('mbway-form').addEventListener('submit', async (e) => {
e.preventDefault();
const phone = document.getElementById('phone').value;

const response = await fetch('/api/pay/mb-way', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ phone_number: phone }),
});

const result = await response.json();
if (!result.error) {
// Show a message while waiting for confirmation
alert('Confirm the payment in the MB WAY app');
}
});
</script>

Testing in sandbox mode

In test mode, you can use special phone numbers to simulate different scenarios without having the MB WAY QLY app:

Phone numberScenario
+351900000001Payment completed successfully
+351900000002Success after a longer wait
+351900000400User rejected the payment in the app
+351900000401Timeout - no confirmation
+351900000402Phone number not registered with MB WAY
+351900000500System error

The full list of test numbers and details is available on the Test environment page.

Common errors

Message / codeWhere it appearsCauseSolution
Phone number is required for MB Way Direct transactions.message (HTTP 400)Missing phone number or a format that cannot be normalized (the number is rejected)Use the +351XXXXXXXXX format
E0506 - Alias does not existadditionalInfoPhone number not registered with MB WAYSuggest another payment method
E0508 - Alias not availableadditionalInfoAlias temporarily unavailableAsk the customer to try again
E0399 - Transaction declinedadditionalInfoPayment rejected (for example, no confirmation or the customer declined it)Ask the customer to try again
E0309 - Transaction not foundadditionalInfoTransaction unknown to the providerRegister the payment again
E0103 - Request validation failedadditionalInfoInvalid request dataCheck that all fields, including device_info, are present
E0099 - Operation not allowed for this aliasadditionalInfoOperation not allowed for this phone numberSuggest another payment method
info

MB WAY is available exclusively to customers with a Portuguese phone number and the MB WAY app installed.