示例#1
0
文件: play.php 项目: maxism/SDK-PHP
<?php

include_once 'bootstrap.php';
try {
    /** @var S2P_SDK\S2P_SDK_Play $play_obj */
    if (!($play_obj = S2P_SDK\S2P_SDK_Module::get_instance('S2P_SDK_Play'))) {
        if ($error_arr = S2P_SDK\S2P_SDK_Module::st_get_error()) {
            die('Error initializing Play class: ' . $error_arr['error_simple_msg']);
        }
        die('Error initializing Play class');
    }
    if (!$play_obj->play()) {
        if ($play_obj->has_error() and $error_arr = $play_obj->get_error()) {
            echo 'ERROR: ' . $error_arr['display_error'];
        } else {
            echo 'Generic error while initiating documentation.';
        }
        exit;
    }
} catch (Exception $ex) {
    die('Cought an error :' . $ex->getMessage());
}
示例#2
0
// !!!!! DO NOT UPDATE TRANSACTION STATUSES IN THIS SCRIPT! WE WILL SEND TRANSACTION DETAILS TO YOUR NOTIFICATION SCIPRT (SETUP IN OUR DASHBOARD)
// !!!!! AND YOU MUST UPDATE TRANSACTION AND ORDER STATUS IN YOUR NOTIFICATION SCRIPT
// !!!!!  THIS SCRIPT IS INTENDED TO NOTIFY YOUR CLIENT ABOUT CURRENT STATUS OF TRANSACTION.
//
// Please note that transaction can be in Open or Processing status which means a final status notification will follow
//
//
include_once S2P_SDK_DIR_CLASSES . 's2p_sdk_return.inc.php';
define('S2P_SDK_RETURN_IDENTIFIER', microtime(true));
S2P_SDK\S2P_SDK_Return::logging_enabled(true);
S2P_SDK\S2P_SDK_Return::logf('--- Return START --------------------', false);
$return_params = array();
$return_params['auto_extract_parameters'] = true;
/** @var S2P_SDK\S2P_SDK_Return $return_obj */
if (!($return_obj = S2P_SDK\S2P_SDK_Module::get_instance('S2P_SDK_Return', $return_params)) or $return_obj->has_error()) {
    if (S2P_SDK\S2P_SDK_Module::st_has_error() and $error_arr = S2P_SDK\S2P_SDK_Module::st_get_error() or !empty($return_obj) and $return_obj->has_error() and $error_arr = $return_obj->get_error()) {
        S2P_SDK\S2P_SDK_Return::logf('Error [' . $error_arr['error_no'] . ']: ' . $error_arr['display_error']);
    } else {
        S2P_SDK\S2P_SDK_Return::logf('Error initiating return object.');
    }
    exit;
}
if (!($return_parameters = $return_obj->get_parameters())) {
    S2P_SDK\S2P_SDK_Return::logf('Couldn\'t extract return parameters.');
    exit;
}
if (empty($return_parameters['MerchantTransactionID'])) {
    S2P_SDK\S2P_SDK_Return::logf('Unknown transaction');
    exit;
}
S2P_SDK\S2P_SDK_Return::logf('Transaction [' . $return_parameters['MerchantTransactionID'] . ']: ');
示例#3
0
// Detecting current directory path - in certain environment setups you might have to manually provide this path
if (!($_current_directory_path = __DIR__)) {
    $_current_directory_path = getcwd();
}
define('S2P_SDK_VERSION', '1.0.34');
define('S2P_SDK_DIR_PATH', $_current_directory_path . '/');
define('S2P_SDK_DIR_CLASSES', $_current_directory_path . '/classes/');
define('S2P_SDK_DIR_STRUCTURES', $_current_directory_path . '/structures/');
define('S2P_SDK_DIR_METHODS', $_current_directory_path . '/methods/');
define('S2P_SDK_DIR_LANGUAGES', $_current_directory_path . '/languages/');
include_once S2P_SDK_DIR_CLASSES . 's2p_sdk_error.inc.php';
include_once S2P_SDK_DIR_CLASSES . 's2p_sdk_language.inc.php';
include_once S2P_SDK_DIR_CLASSES . 's2p_sdk_module.inc.php';
include_once S2P_SDK_DIR_CLASSES . 's2p_sdk_database.inc.php';
include_once S2P_SDK_DIR_CLASSES . 's2p_sdk_wrapper.inc.php';
include_once S2P_SDK_DIR_STRUCTURES . 's2p_sdk_scope_variable.inc.php';
include_once S2P_SDK_DIR_STRUCTURES . 's2p_sdk_scope_structure.inc.php';
if (!S2P_SDK\S2P_SDK_Language::define_language(S2P_SDK\S2P_SDK_Language::LANG_EN, array('title' => 'English', 'files' => array(S2P_SDK_DIR_LANGUAGES . 'en.csv'))) or !S2P_SDK\S2P_SDK_Language::define_language(S2P_SDK\S2P_SDK_Language::LANG_RO, array('title' => 'Romana', 'files' => array(S2P_SDK_DIR_LANGUAGES . 'ro.csv')))) {
    // Do something if we cannot initialize English language
    S2P_SDK\S2P_SDK_Language::language_container()->throw_error();
} else {
    S2P_SDK\S2P_SDK_Language::language_container()->set_current_language(S2P_SDK\S2P_SDK_Language::LANG_EN);
}
S2P_SDK\S2P_SDK_Module::st_debugging_mode(false);
S2P_SDK\S2P_SDK_Module::st_detailed_errors(false);
S2P_SDK\S2P_SDK_Module::st_throw_errors(false);
if (!@file_exists(S2P_SDK_DIR_PATH . 'config.inc.php')) {
    die('SDK config file not found. Please configure bootstrap file.');
}
include_once S2P_SDK_DIR_PATH . 'config.inc.php';
示例#4
0
S2P_SDK\S2P_SDK_Module::st_debugging_mode(true);
S2P_SDK\S2P_SDK_Module::st_throw_errors(false);
$api_parameters = array();
// By default, API will check S2P_SDK_API_KEY, S2P_SDK_SITE_ID and S2P_SDK_ENVIRONMENT constats set in config.inc.php
// If you want to override these constants (per request) uncomment lines below and provide values to override
// $api_parameters['api_key'] = '{PROVIDED_APIKEY}';
// $api_parameters['site_id'] = '{PROVIDED_SITE_ID}';
// $api_parameters['environment'] = 'test'; // test or live
$api_parameters['method'] = 'methods';
$api_parameters['func'] = 'list_all';
$api_parameters['get_variables'] = array();
$api_parameters['method_params'] = array();
$call_params = array();
$finalize_params = array();
$finalize_params['redirect_now'] = false;
if (!($call_result = S2P_SDK\S2P_SDK_Module::quick_call($api_parameters, $call_params, $finalize_params))) {
    echo 'API call error: ';
    if ($error_arr = S2P_SDK\S2P_SDK_Module::st_get_error() and !empty($error_arr['display_error'])) {
        echo $error_arr['display_error'];
    } else {
        echo 'Unknown error.';
    }
} else {
    echo 'API call time: ' . $call_result['call_microseconds'] . 'ms<br/>' . "\n";
    if (!empty($call_result['finalize_result']['should_redirect']) and !empty($call_result['finalize_result']['redirect_to'])) {
        echo '<br/>' . "\n" . 'Go to <a href="' . $call_result['finalize_result']['redirect_to'] . '">' . $call_result['finalize_result']['redirect_to'] . '</a> to complete transaction<br/>' . "\n" . '<br/>' . "\n";
    }
    echo 'Call result:<br>' . "\n" . '<pre>';
    var_dump($call_result['call_result']);
    echo '</pre>';
}
示例#5
0
//
// !!!!! THIS IS THE SCRIPT WHICH HANDLES ALL SERVER COMMUNICATION. THIS COMMUNICATION HAPPENS IN BACKGROUND, SO THIS SCRIPT WILL NOT NEED A FRONT-END INTERFACE.
// !!!!! THIS SCRIPT WILL ONLY HAVE TO ECHO MESSAGES AS DESCRIBED IN MANUAL FOR EACH NOTIFICATION TYPE RECEIVED.
//
//
include_once S2P_SDK_DIR_CLASSES . 's2p_sdk_notification.inc.php';
include_once S2P_SDK_DIR_CLASSES . 's2p_sdk_helper.inc.php';
include_once S2P_SDK_DIR_METHODS . 's2p_sdk_meth_payments.inc.php';
define('S2P_SDK_NOTIFICATION_IDENTIFIER', microtime(true));
S2P_SDK\S2P_SDK_Notification::logging_enabled(true);
S2P_SDK\S2P_SDK_Notification::logf('--- Notification START --------------------', false);
$notification_params = array();
$notification_params['auto_extract_parameters'] = true;
/** @var S2P_SDK\S2P_SDK_Notification $notification_obj */
if (!($notification_obj = S2P_SDK\S2P_SDK_Module::get_instance('S2P_SDK_Notification', $notification_params)) or $notification_obj->has_error()) {
    if (S2P_SDK\S2P_SDK_Module::st_has_error() and $error_arr = S2P_SDK\S2P_SDK_Module::st_get_error() or !empty($notification_obj) and $notification_obj->has_error() and $error_arr = $notification_obj->get_error()) {
        $error_msg = 'Error [' . $error_arr['error_no'] . ']: ' . $error_arr['display_error'];
    } else {
        $error_msg = 'Error initiating notification object.';
    }
    S2P_SDK\S2P_SDK_Notification::logf($error_msg);
    exit;
}
if (!$notification_obj->check_authentication()) {
    if ($notification_obj->has_error() and $error_arr = $notification_obj->get_error()) {
        S2P_SDK\S2P_SDK_Notification::logf('Error: ' . $error_arr['display_error']);
    } else {
        S2P_SDK\S2P_SDK_Notification::logf('Authentication failed.');
    }
    exit;
}