Exemplo n.º 1
0
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Client: GateCX v0.0.3'));
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_USERPWD, $GATEWAY['private-key'] . ":" . NULL);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
    curl_setopt($ch, CURLOPT_CAINFO, realpath(dirname(__FILE__) . "/cacert.pem"));
    $return = curl_exec($ch);
    curl_close($ch);
    return $return;
}
# Ensure that the module is active before attempting to run any code
$gateway = new Gateway();
if (!$gateway->isActiveGateway($gatewaymodule) || !$gateway->load($gatewaymodule)) {
    Terminus::getInstance()->doDie('Module not Active');
}
$pdo = Capsule::connection()->getPdo();
# Process and store transaction
if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) {
    $ca = new WHMCS_ClientArea();
    # Check login status
    if ($ca->isLoggedIn()) {
        $invoice_id = (int) $_REQUEST['id'];
        $store_token = $_REQUEST['token'];
        $currency = $_REQUEST['currency'];
        $amount = (int) $_REQUEST['amount'];
        if (preg_match("#^[A-Z]{3}\$#", $currency) && preg_match("#^[a-zA-Z 0-9\\_\\-]*\$#", $store_token)) {
            //Get invoice details
Exemplo n.º 2
0
Arquivo: gmp.php Projeto: sercba/gmp
use WHMCS\Module\Gateway;
use WHMCS\Terminus;
/** @type WHMCS\Application $whmcs */
# Required File Includes
include "../../../init.php";
include ROOTDIR . DIRECTORY_SEPARATOR . 'includes/functions.php';
include ROOTDIR . DIRECTORY_SEPARATOR . 'includes/gatewayfunctions.php';
include ROOTDIR . DIRECTORY_SEPARATOR . 'includes/invoicefunctions.php';
include "../gmp/mercadopago.php";
$gatewayModule = 'gmp';
# Enter your gateway module name here replacing template
/**
 * Ensure that the module is active before attempting to run any code
 */
$gateway = new Gateway();
if (!$gateway->isActiveGateway($gatewayModule) || !$gateway->load($gatewayModule)) {
    Terminus::getInstance()->doDie('Module not Active');
}
$GATEWAY = $gateway->getParams();
$mp = new MP($GATEWAY['client_id'], $GATEWAY['client_secret']);
if ($GATEWAY['testmode']) {
    $mp->sandbox_mode(TRUE);
}
$payment_info = $mp->get_payment_info($_GET["id"]);
$debug = array('json' => json_encode($payment_info));
$status = "0";
if ($payment_info["status"] == 200) {
    $data = $payment_info["response"]["collection"];
    if (!$data["sandbox"] && "approved" == $data["status"]) {
        $transactionId = $data["id"];