示例#1
0
function presta_paybox_payer_resilier_dist($uid)
{
    $parm = paybox_pbx_ids();
    $args = "VERSION=001" . "&TYPE=001" . "&SITE=" . str_pad($parm['PBX_SITE'], 7, "0", STR_PAD_LEFT) . "&MACH=" . str_pad($parm['PBX_RANG'], 3, "0", STR_PAD_LEFT) . "&IDENTIFIANT=" . $parm['PBX_IDENTIFIANT'] . "&ABONNEMENT=" . $uid;
    $url = _PAYBOX_URL_RESIL . "?" . $args;
    include_spip('inc/distant');
    $reponse = recuperer_page($url);
    spip_log("uid:{$uid}, {$url}, reponse:{$reponse}", 'paybox_abos_resil');
    parse_str($reponse, $res);
    if ($res['ACQ'] == 'OK' and $res['ABONNEMENT'] == $uid) {
        return true;
    }
    return false;
}
示例#2
0
function presta_paybox_call_request_dist($id_transaction, $transaction_hash, $abo = false, $cartes = array('CB', 'VISA', 'EUROCARD_MASTERCARD', 'E_CARD'))
{
    if (!($row = sql_fetsel("*", "spip_transactions", "id_transaction=" . intval($id_transaction) . " AND transaction_hash=" . sql_quote($transaction_hash)))) {
        return "";
    }
    if (!$row['id_auteur'] and $GLOBALS['visiteur_session']['id_auteur']) {
        sql_updateq("spip_transactions", array("id_auteur" => intval($row['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur'])), "id_transaction=" . intval($id_transaction));
    }
    // recuperer l'email
    $mail = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($row['id_auteur']));
    // passage en centimes d'euros
    $montant = intval(100 * $row['montant']);
    if (strlen($montant) < 3) {
        $montant = str_pad($montant, 3, '0', STR_PAD_LEFT);
    }
    //		Affectation des parametres obligatoires
    $parm = paybox_pbx_ids();
    $parm['PBX_OUTPUT'] = "C";
    // recuperer uniquement les hidden
    $parm['PBX_LANGUE'] = "FRA";
    $parm['PBX_DEVISE'] = "978";
    $parm['PBX_TOTAL'] = $montant;
    $parm['PBX_PORTEUR'] = defined('_PBX_PORTEUR') ? _PBX_PORTEUR : $mail;
    $parm['PBX_CMD'] = intval($id_transaction);
    $parm['PBX_RETOUR'] = 'montant:M;id_transaction:R;auth:A;trans:S;abo:B;erreur:E;valid:D;sign:K';
    $parm['PBX_EFFECTUE'] = generer_url_action('bank_response', "bankp=paybox", true, true);
    $parm['PBX_REFUSE'] = generer_url_action('bank_cancel', "bankp=paybox", true, true);
    $parm['PBX_ANNULE'] = generer_url_action('bank_cancel', "bankp=paybox", true, true);
    if ($abo and $id_abonnement = sql_getfetsel("id_abonnement", "spip_abonnements_transactions", "id_transaction=" . intval($id_transaction)) and $montant_echeance = sql_getfetsel('prix_echeance', 'spip_abonnements', 'id_abonnement=' . intval($id_abonnement))) {
        $montant_echeance = str_pad(intval(100 * $montant_echeance), 10, "0", STR_PAD_LEFT);
        // infos de l'abonnement :
        // montant identique recurrent, frequence mensuelle, a date anniversaire, sans delai
        $parm['PBX_CMD'] .= "IBS_2MONT{$montant_echeance}" . "IBS_NBPAIE00" . "IBS_FREQ01" . "IBS_QUAND00";
    }
    //var_dump($parm);
    $cartes_possibles = array('CB' => 'presta/paybox/logo/CB.gif', 'VISA' => 'presta/paybox/logo/VISA.gif', 'EUROCARD_MASTERCARD' => 'presta/paybox/logo/MASTERCARD.gif', 'E_CARD' => 'presta/paybox/logo/E-CB.gif', 'AMEX' => 'presta/paybox/logo/AMEX.gif', 'AURORE' => 'presta/paybox/logo/AURORE.gif');
    include_spip('inc/filtres_mini');
    $contexte = array('hidden' => array(), 'action' => _PAYBOX_URL, 'backurl' => url_absolue(self()), 'id_transaction' => $id_transaction);
    foreach ($cartes as $carte) {
        if ($cartes_possibles[$carte]) {
            $parm['PBX_TYPEPAIEMENT'] = 'CARTE';
            $parm['PBX_TYPECARTE'] = $carte;
            $contexte['hidden'][$carte] = paybox_exec_request($parm);
            $contexte['logo'][$carte] = $cartes_possibles[$carte];
        }
    }
    return $contexte;
}