コード例 #1
0
ファイル: bank_response.php プロジェクト: rougerose/bank
function action_bank_response_dist($cancel = null, $auto = null)
{
    if (isset($GLOBALS['meta']['bank_paiement']) and $prestas = unserialize($GLOBALS['meta']['bank_paiement']) and count($prestas = $prestas['presta'])) {
        $auto = $auto ? "auto" : "";
        $result = false;
        // intercepter les retours depuis un presta actif
        if ($p = _request('bankp') and (isset($prestas[$p]) and $prestas[$p] or $p == 'gratuit')) {
            $call_response = charger_fonction('response', "presta/{$p}/call");
            spip_log('call_' . $auto . 'response : ' . $_SERVER['REQUEST_URI'], "{$p}{$auto}");
            list($id_transaction, $result) = $call_response();
            spip_log('call_' . $auto . 'response : ' . "{$id_transaction}/{$result}", "{$p}{$auto}");
        } else {
            spip_log("Prestataire {$p} inconnu ou inactif", 'bank_response');
        }
        // fall back si le presta n'a rien renvoye de lisible
        // et qu'on a bien id=id_transaction;hash dans l'url
        if (!$result and !$id_transaction and $id = _request('id') and $id = explode(';', $id) and count($id) == 2 and $id_transaction = reset($id) and $hash = end($id)) {
            $id_transaction = sql_getfetsel("id_transaction", "spip_transactions", "id_transaction=" . intval($id_transaction) . " AND transaction_hash=" . sql_quote($hash));
            if ($id_transaction) {
                sql_updateq("spip_transactions", array('message' => 'Transaction annulée', 'statut' => 'echec', 'mode' => $p), 'id_transaction=' . intval($id_transaction) . " AND statut='commande'");
            }
        }
        if (!$auto) {
            redirige_apres_retour_transaction($p, 'acte', $cancel ? false : $result, $id_transaction);
        }
        die;
        // mourir silencieusement
    } else {
        spip_log('Aucun prestataire de paiement configure', 'bank_response');
    }
    die;
}
コード例 #2
0
ファイル: bank_response.php プロジェクト: nursit/bank
function action_bank_response_dist($cancel = null, $auto = null, $presta = null)
{
    $id_transaction = 0;
    $auto = $auto ? "auto" : "";
    $result = false;
    // intercepter les retours depuis un presta
    // actif ou non (le paiement a ete fait en banque, on le decode dans tous les cas du moment qu'on sait le faire)
    if (!$presta) {
        $presta = _request('bankp');
    }
    include_spip('inc/bank');
    if ($presta and $config = bank_config($presta) and !isset($config['erreur'])) {
        $presta = $config['presta'];
        // en cas de renommage
        $test = "";
        if (isset($config['mode_test']) and $config['mode_test']) {
            $test = "_test";
        }
        if (!$auto or !($call_response = charger_fonction('autoresponse', "presta/{$presta}/call", true))) {
            $call_response = charger_fonction('response', "presta/{$presta}/call");
        }
        if ($cancel) {
            define('_BANK_CANCEL_TRANSACTION', true);
        }
        // si on a recu un POST, le traduire en request_uri pour les logs et faciliter le code de certains modules
        $GLOBALS['BANK_REQUEST_URI'] = $_SERVER['REQUEST_URI'];
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            $q = http_build_query($_POST);
            if (strpos($GLOBALS['BANK_REQUEST_URI'], "?") !== false) {
                $GLOBALS['BANK_REQUEST_URI'] .= "&{$q}";
            } else {
                $GLOBALS['BANK_REQUEST_URI'] .= "?{$q}";
            }
        }
        $inactif = "";
        if (!$config['actif']) {
            $inactif = "(inactif) ";
        }
        spip_log('call_' . $auto . 'response ' . $inactif . ': ' . $GLOBALS['BANK_REQUEST_URI'], "{$presta}{$auto}{$test}");
        list($id_transaction, $result) = $call_response($config);
        spip_log('call_' . $auto . 'response ' . $inactif . ': ' . "{$id_transaction}/{$result}", "{$presta}{$auto}{$test}");
    } else {
        spip_log("Prestataire {$presta} inconnu", 'bank_response' . _LOG_ERREUR);
    }
    // fall back si le presta n'a rien renvoye de lisible
    // et qu'on a bien id=id_transaction;hash dans l'url
    if (!$result and !$id_transaction and $id = _request('id') and $id = explode(';', $id) and count($id) == 2 and $id_transaction = reset($id) and $hash = end($id)) {
        $id_transaction = sql_getfetsel("id_transaction", "spip_transactions", "id_transaction=" . intval($id_transaction) . " AND transaction_hash=" . sql_quote($hash));
        if ($id_transaction) {
            $set = array('mode' => $presta, 'statut' => 'echec', 'message' => 'Transaction annulée');
            sql_updateq("spip_transactions", $set, 'id_transaction=' . intval($id_transaction) . " AND statut=" . sql_quote('commande'));
        }
    }
    // notifier les reglement en echec/annule
    if (!$result and $id_transaction and $row = sql_fetsel('*', 'spip_transactions', 'id_transaction=' . intval($id_transaction))) {
        pipeline('trig_bank_reglement_en_echec', array('args' => array('statut' => 'echec', 'mode' => $row['mode'], 'type' => $row['abo_uid'] ? 'abo' : 'acte', 'id_transaction' => $id_transaction, 'row' => $row), 'data' => ''));
    }
    if (!$auto) {
        $abo = sql_getfetsel("abo_uid", "spip_transactions", "id_transaction=" . intval($id_transaction));
        return redirige_apres_retour_transaction($presta, !$abo ? 'acte' : 'abo', $cancel ? false : $result, $id_transaction);
    }
    die;
    // mourir silencieusement
}
コード例 #3
0
ファイル: config.php プロジェクト: nursit/bank
function action_paypalexpress_checkoutpayment_dist($arg = null)
{
    if (is_null($arg)) {
        $securiser_action = charger_fonction('securiser_action', 'inc');
        $arg = $securiser_action();
    }
    $arg = explode("-", $arg);
    $payerid = array_shift($arg);
    $mode = implode("-", $arg);
    include_spip("inc/bank");
    $config = bank_config($mode);
    include_spip("presta/paypalexpress/inc/paypalexpress");
    $res = bank_paypalexpress_checkoutpayment($payerid, $config);
    list($id_transaction, $success) = $res;
    include_spip("action/bank_response");
    redirige_apres_retour_transaction("paypalexpress", "acte", $success, $id_transaction);
}