コード例 #1
0
function eStore_auth_net_ipn_processor_listener()
{
    if (isset($_REQUEST['x_invoice_num']) && isset($_REQUEST['x_trans_id']) && isset($_REQUEST['x_amount'])) {
        if (get_option('eStore_use_authorize_gateway')) {
            //Auth.net is enabled
            //Process the IPN
        } else {
            eStore_payment_debug("Authorize.net payment gateway is not enabled in eStore settings. This IPN will not be processed", false);
        }
    } else {
        return;
    }
    status_header(200);
    include_once 'lib/gateway/Authorize.php';
    include_once 'eStore_process_payment_data.php';
    // Create an instance of the authorize.net library
    $myAuthorize = new Authorize();
    // Log the IPN results
    $debug_on = get_option('eStore_cart_enable_debug');
    if ($debug_on) {
        $myAuthorize->ipnLog = TRUE;
    }
    // Specify your authorize api and transaction id
    $authorize_login_id = get_option('eStore_authorize_login');
    $authorize_tx_key = get_option('eStore_authorize_tx_key');
    $myAuthorize->setUserInfo($authorize_login_id, $authorize_tx_key);
    // Enable test mode if needed
    if (get_option('eStore_cart_enable_sandbox')) {
        $myAuthorize->enableTestMode();
    }
    // Check validity and process
    if ($myAuthorize->validateIpn()) {
        handle_payment_data($myAuthorize->ipnData, "authorize");
    } else {
        $_SESSION['eStore_tx_result'] = $myAuthorize->lastError;
        //Ipn validation failed... redirect to the cancel URL
        $return = get_option('cart_cancel_from_paypal_url');
        if (empty($return)) {
            $return = get_bloginfo('wpurl');
        }
        $redirection_parameter = 'Location: ' . $return;
        header($redirection_parameter);
        exit;
    }
}
コード例 #2
0
function espresso_process_authnet($payment_data)
{
    // Include the authorize.net library
    include_once 'Authorize.php';
    // Create an instance of the authorize.net library
    $myAuthorize = new Authorize();
    echo '<!--Event Espresso Authorize.net SIM Gateway Version ' . $myAuthorize->gateway_version . '-->';
    // Log the IPN results
    $myAuthorize->ipnLog = TRUE;
    $authnet_settings = get_option('event_espresso_authnet_settings');
    $authnet_login_id = $authnet_settings['authnet_login_id'];
    $authnet_transaction_key = $authnet_settings['authnet_transaction_key'];
    // Enable test mode if needed
    //4007000000027  <-- test successful visa
    //4222222222222  <-- test failure card number
    if ($authnet_settings['use_sandbox']) {
        $myAuthorize->enableTestMode();
        $email_transaction_dump = true;
    }
    // Specify your authorize login and secret
    $myAuthorize->setUserInfo($authnet_login_id, $authnet_transaction_key);
    $payment_data['txn_type'] = 'authorize.net SIM';
    $payment_data['payment_status'] = "Incomplete";
    if (!empty($_REQUEST['x_trans_id'])) {
        $payment_data['txn_id'] = $_REQUEST['x_trans_id'];
    } else {
        $payment_data['txn_id'] = 0;
    }
    $payment_data['txn_details'] = serialize($_REQUEST);
    $curl_session_id = uniqid('', true);
    global $wpdb;
    $sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET attendee_session = '" . $curl_session_id . "' WHERE attendee_session ='" . $payment_data['attendee_session'] . "' ";
    $wpdb->query($sql);
    $payment_data['attendee_session'] = $curl_session_id;
    // Check validity and write down it
    if ($myAuthorize->validateIpn()) {
        $payment_data['txn_id'] = $myAuthorize->ipnData['x_trans_id'];
        $payment_data['txn_details'] = serialize($myAuthorize->ipnData);
        //file_put_contents('authorize.txt', 'SUCCESS' . date("m-d-Y")); //Used for debugging purposes
        //Be sure to echo something to the screen so authent knows that the ipn works
        //store the results in reusable variables
        if ($myAuthorize->ipnData['x_response_code'] == 1) {
            ?>
			<h2><?php 
            _e('Thank You!', 'event_espresso');
            ?>
</h2>
			<p><?php 
            _e('Your transaction has been processed.', 'event_espresso');
            ?>
</p>
			<?php 
            $payment_data['payment_status'] = 'Completed';
        } else {
            ?>
			<h2 style="color:#F00;"><?php 
            _e('There was an error processing your transaction!', 'event_espresso');
            ?>
</h2>
			<p><strong>Error:</strong> (Payment was declined)</p>
			<?php 
            $payment_data['payment_status'] = 'Payment Declined';
        }
        //Debugging option
        $email_transaction_dump = true;
        if ($email_transaction_dump == true) {
            // For this, we'll just email ourselves ALL the data as plain text output.
            $subject = 'Authorize.net Notification - Gateway Variable Dump';
            $body = "An authorize.net payment notification was successfully recieved\n";
            $body .= "from " . $myAuthorize->ipnData['x_email'] . " on " . date('m/d/Y');
            $body .= " at " . date('g:i A') . "\n\nDetails:\n";
            foreach ($myAuthorize->ipnData as $key => $value) {
                $body .= "\n{$key}: {$value}\n";
            }
            wp_mail($payment_data['contact'], $subject, $body);
        }
    } else {
        ?>
		<h2 style="color:#F00;"><?php 
        _e('There was an error processing your transaction!', 'event_espresso');
        ?>
</h2>
		<p><strong>Error:</strong> (IPN response did not validate) ?></p>
		<?php 
        if (is_writable('authorize.txt')) {
            file_put_contents('authorize.txt', "FAILURE\n\n" . $myAuthorize->ipnData);
        }
        //echo something to the screen so authent knows that the ipn works
        $subject = 'Instant Payment Notification - Gateway Variable Dump';
        $body = "An instant payment notification failed\n";
        $body .= "from " . $myAuthorize->ipnData['x_email'] . " on " . date('m/d/Y');
        $body .= " at " . date('g:i A') . "\n\nDetails:\n";
        foreach ($myAuthorize->ipnData as $key => $value) {
            $body .= "\n{$key}: {$value}\n";
        }
        wp_mail($payment_data['contact'], $subject, $body);
    }
    add_action('action_hook_espresso_email_after_payment', 'espresso_email_after_payment');
    return $payment_data;
}
コード例 #3
0
include_once 'eStore_process_payment_data.php';
status_header(200);
// Create an instance of the authorize.net library
$myAuthorize = new Authorize();
// Log the IPN results
$debug_on = get_option('eStore_cart_enable_debug');
if ($debug_on) {
    $myAuthorize->ipnLog = TRUE;
}
// Specify your authorize api and transaction id
$authorize_login_id = get_option('eStore_authorize_login');
$authorize_tx_key = get_option('eStore_authorize_tx_key');
$myAuthorize->setUserInfo($authorize_login_id, $authorize_tx_key);
// Enable test mode if needed
if (get_option('eStore_cart_enable_sandbox')) {
    $myAuthorize->enableTestMode();
}
// Check validity and process
if ($myAuthorize->validateIpn()) {
    handle_payment_data($myAuthorize->ipnData, "authorize");
} else {
    $_SESSION['eStore_tx_result'] = $myAuthorize->lastError;
    //Ipn validation failed... redirect to the cancel URL
    $return = get_option('cart_cancel_from_paypal_url');
    if (empty($return)) {
        $return = get_bloginfo('wpurl');
    }
    $redirection_parameter = 'Location: ' . $return;
    header($redirection_parameter);
    exit;
}
コード例 #4
0
ファイル: ipn.php プロジェクト: rexcarnation/XtraUpload
 function authorize()
 {
     // make sure there are no timeouts...
     echo 'Processing...';
     flush();
     $gate = $this->db->get_where('gateways', array('name' => 'authorize'))->row();
     $gate_conf = unserialize($gate->settings);
     // Include the paypal library
     include_once APPPATH . 'libraries/payment/Authorize.php';
     $this->gateway = '2';
     // Create an instance of the authorize.net library
     $myAuthorize = new Authorize();
     // Log the IPN results
     // $myAuthorize->ipnLog = TRUE;
     // Specify your authorize login and secret
     $myAuthorize->setUserInfo($gate_conf['login'], $gate_conf['secret']);
     // Enable test mode if needed
     $myAuthorize->enableTestMode();
     // Check validity and write down it
     if ($myAuthorize->validateIpn()) {
         $settings = unserialize(base64_decode($myAuthorize->ipnData['x_Cust_ID']));
         if ($settings['type'] == 'reg') {
             $this->_newUserPayment($settings['user_id'], $myAuthorize->ipnData['x_Amount']);
             redirect('/user/pay_complete');
         }
         redirect('/user/pay_cancel');
     } else {
         $this->_logError($myAuthorize->ipnData);
         redirect('/user/pay_cancel');
     }
 }