PHP code example of martinvondrak / platba-mobilom-php-sdk

1. Go to this page and download the library: Download martinvondrak/platba-mobilom-php-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/ */

    

martinvondrak / platba-mobilom-php-sdk example snippets


use MartinVondrak\PlatbaMobilom\PlatbaMobilomClient;

$pid = 1; // merchant ID
$url = 'https//www.shop.com/callback'; // URL of callback where user will be redirected from PlatbaMobilom.sk
$pwd = 'SecretPass'; // passphrase used for signing requests
$email = '[email protected]'; // merchant email (optional)
$debug = true; // flag whether production or test environment is used
$platbaMobilomClient = new PlatbaMobilomClient($pid, $url, $pwd, $email, $debug);

use MartinVondrak\PlatbaMobilom\Http\Request;

$id = 'aef4622'; // unique ID of payment
$description = 'Payment in www.shop.com'; // description of payment
$price = 6.5; // amount to pay in EUR
$request = new Request($id, $description, $price);
// client from previous step
$redirectUrl = $platbaMobilomClient->getGatewayUrl($request);
// now redirect user to $redirectUrl

use MartinVondrak\PlatbaMobilom\Exception\InvalidSignatureException;
use MartinVondrak\PlatbaMobilom\Http\Response;

// following attributes are in query string in request on callback url from first step
$id = $_GET['ID']; // unique ID of payment
$result = $_GET['RES']; // status of payment
$responseSignature = $_GET['SIGN']; // signature of received parameters
$phone = $_GET['PHONE']; // phone number used for payment (optional)
$response = new Response($id, $result, $responseSignature, $phone);

try {
    // client from first step
    if ($platbaMobilomClient->checkResponse($response)) {
        // paid
    } else {
        // not paid or error
    }
} catch (InvalidSignatureException $ex) {
    // signature is not valid for received data
}

$ composer