1. Go to this page and download the library: Download finergy/mia-pos-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
finergy / mia-pos-sdk example snippets
use Finergy\MiaPosSdk\MiaPosSdk;
$baseUrl = 'https://ecomm-test.miapos.md/';
$merchantId = 'your_merchant_id';
$secretKey = 'your_secret_key';
$sdk = MiaPosSdk::getInstance($baseUrl, $merchantId, $secretKey);
$paymentData = [
'terminalId' => 'TE0001',
'orderId' => 'order12345',
'amount' => 150.75,
'currency' => 'MDL',
'language' => 'ro',
'payDescription' => 'Payment for order #12345',
'callbackUrl' => 'http://your_callback_url',
'successUrl' => 'http://your_success_url',
'failUrl' => 'http://your_fail_url',
];
$response = $sdk->createPayment($paymentData);
$paymentId = $response['paymentId'];
$checkoutPage = $response['checkoutPage'];
// Save $paymentId in your database and redirect the client to $checkoutPage
header("Location: $checkoutPage");
use Finergy\MiaPosSdk\MiaPosSdk;
$baseUrl = 'https://ecomm-test.miapos.md/';
$merchantId = 'your_merchant_id';
$secretKey = 'your_secret_key';
$sdk = MiaPosSdk::getInstance($baseUrl, $merchantId, $secretKey);
// Retrieve orderId from the request parameters
$orderId = $_GET['orderId'];
// Fetch paymentId from your database using orderId
$paymentId = getPaymentIdFromDatabase($orderId);
$response = $sdk->getPaymentStatus($paymentId);
if ($response['status'] === 'FAILED') {
echo "Payment failed. Please try again.";
} else {
echo "Payment successful!";
// Update order status in your database
}
use Finergy\MiaPosSdk\MiaPosSdk;
$baseUrl = 'https://ecomm-test.miapos.md/';
$merchantId = 'your_merchant_id';
$secretKey = 'your_secret_key';
$sdk = MiaPosSdk::getInstance($baseUrl, $merchantId, $secretKey);
// Retrieve orderId from the request parameters
$orderId = $_GET['orderId'];
// Fetch paymentId from your database using orderId
$paymentId = getPaymentIdFromDatabase($orderId);
$response = $sdk->getPaymentStatus($paymentId);
if ($response['status'] === 'SUCCESS') {
echo "Payment successful! Order ID: " . $response['orderId'];
// Update order status in your database
} else {
echo "Payment could not be verified. Please contact support.";
}
use Finergy\MiaPosSdk\MiaPosSdk;
$baseUrl = 'https://ecomm-test.miapos.md/';
$merchantId = 'your_merchant_id';
$secretKey = 'your_secret_key';
$sdk = MiaPosSdk::getInstance($baseUrl, $merchantId, $secretKey);
// Retrieve callback data (replace with actual input)
$inputJson = file_get_contents('php://input');
$callbackData = json_decode($inputJson, true);
$result = $callbackData['result'];
$signature = $callbackData['signature'];
$signString = $sdk->formSignStringByResult($result);
$isValidSignature = $sdk->verifySignature($signString, $signature);
if ($isValidSignature) {
echo "Callback verified successfully!";
// Update order status in your database based on $result['status']
} else {
echo "Invalid callback signature!";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.