Esempio n. 1
0
function gjb_confirmarPagamentUsuari($year, &$token, $CheckoutDetails = null)
{
    if (empty($token)) {
        return false;
    }
    global $current_user;
    if ($CheckoutDetails == null) {
        $CheckoutDetails = gjb_obtePaypalTokenInfo($token);
    }
    if (!gjb_comprovaNoError($CheckoutDetails)) {
        gjb_obteNouPaypalTokenUsuari($year, $token);
        return false;
    }
    if (!gjb_haIntroduitMetodePagament($CheckoutDetails)) {
        return false;
    }
    $ppParams = array('METHOD' => 'DoExpressCheckoutPayment', 'PAYMENTACTION' => 'Sale', 'AMT' => $CheckoutDetails['AMT'], 'TOKEN' => $token, 'PAYERID' => $CheckoutDetails['PAYERID']);
    $response = hashCall($ppParams);
    //echo "<pre> DEBUG ".__FUNCTION__.":\n\n".var_export($response, true)."</pre>";
    $status = strtoupper($response['PAYMENTSTATUS']);
    if (gjb_comprovaNoError($response) || strcmp($status, 'COMPLETED') == 0) {
        gjb_updateUserInfo($year, $current_user->ID, array('Confirmat' => '1'));
    } else {
        gjb_obteNouPaypalTokenUsuari($year, $token);
        return false;
    }
    return true;
}
Esempio n. 2
0
function gjb_obteFormulari($year, $closed, $limit)
{
    global $lang;
    global $wpdb;
    global $current_user;
    $command = gjb_getCommand();
    if (strcmp($command, "registrar") == 0) {
        gjb_registrarUsuari($year);
    }
    $userinfo = gjb_getUserInfo($year, $current_user->ID);
    if (count($userinfo) == 0) {
        $num_users = gjb_getUserRegistred($year);
        if ($limit != 0 && $limit <= $num_users) {
            return $lang['ERR_NO_PLACES'];
        }
        return gjb_obteFormulariRegistre($year);
    }
    $token = $userinfo[0]->PaypalToken;
    $confirmat = $userinfo[0]->Confirmat == 1 ? true : false;
    if (!$confirmat) {
        if (strcmp($command, "confirmar") == 0) {
            $confirmat = gjb_confirmarPagamentUsuari($year, $token);
            if ($confirmat) {
                $email = $userinfo[0]->Email;
                $nom = html_entity_decode($userinfo[0]->Nom);
                $mailbody = $lang['EMAIL_HELLO'] . " " . $nom . ",\n\n" . $lang['EMAIL_SUCCESS_TEXT'];
                $mailbody = html_entity_decode($mailbody);
                $subject = html_entity_decode($lang['EMAIL_SUCCESS_SUBJECT']);
                wp_mail($email, $subject, $mailbody);
            }
        } else {
            if (strcmp($command, "cancelpago") == 0) {
                gjb_obteNouPaypalTokenUsuari($year, $token);
            }
        }
    }
    if ($confirmat) {
        return gjb_obteVistaUsuariConfirmat($year, $userinfo);
    }
    if (empty($token)) {
        gjb_obteNouPaypalTokenUsuari($year, $token);
    }
    if (!empty($token)) {
        $response = gjb_obtePaypalTokenInfo($token);
        if (!gjb_comprovaNoError($response)) {
            gjb_obteNouPaypalTokenUsuari($year, $token);
            if (!empty($token)) {
                gjb_obteVistaUsuariPerPagar($year, $token);
            }
        } else {
            if (gjb_haIntroduitMetodePagament($response)) {
                if (GJB_PAY_ON_PAYPAL) {
                    $confirmat = gjb_confirmarPagamentUsuari($year, $token, $response);
                }
                if ($confirmat) {
                    return gjb_obteVistaUsuariConfirmat($year);
                } else {
                    return gjb_obteVistaUsuariPerConfirmar($year, $token, $response, $userinfo);
                }
            } else {
                return gjb_obteVistaUsuariPerPagar($year, $token);
            }
        }
    }
    return $lang['ERR_PAYMENT'];
}