예제 #1
0
 /**
  * IPN->paypal()
  *
  * Validate PayPal payments
  *
  * @access	public
  * @return	none
  */
 public function paypal()
 {
     // Include the paypal library
     include_once APPPATH . 'libraries/payment/Paypal.php';
     $this->gateway = '1';
     // Create an instance of the paypal library
     $myPaypal = new Paypal();
     // Log the IPN results
     // $myPaypal->ipnLog = TRUE;
     // Enable test mode if needed
     if (defined('XUDEBUG') and XUDEBUG == true) {
         $myPaypal->enableTestMode();
     }
     // Check validity and write down it
     if ($myPaypal->validateIpn()) {
         if ($myPaypal->ipnData['payment_status'] == 'Completed') {
             $settings = unserialize(base64_decode($myPaypal->ipnData['custom']));
             if ($settings['type'] == 'reg') {
                 $this->_newUserPayment($settings['user_id'], $myPaypal->ipnData['amount']);
                 redirect('/user/pay_complete');
             }
             redirect('/user/pay_cancel');
         } else {
             $this->_logError($myPaypal->ipnData);
             redirect('/user/pay_cancel');
         }
     }
     redirect('/user/pay_cancel');
 }
예제 #2
0
function espresso_process_paypal($payment_data)
{
    do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
    $payment_data['txn_type'] = 'Paypal';
    $payment_data['txn_id'] = 0;
    $payment_data['payment_status'] = 'Incomplete';
    $payment_data['txn_details'] = serialize($_REQUEST);
    include_once 'Paypal.php';
    $myPaypal = new Paypal();
    echo '<!--Event Espresso PayPal Gateway Version ' . $myPaypal->gateway_version . '-->';
    $myPaypal->ipnLog = TRUE;
    $paypal_settings = get_option('event_espresso_paypal_settings');
    if ($paypal_settings['use_sandbox']) {
        $myPaypal->enableTestMode();
    }
    if ($myPaypal->validateIpn()) {
        $payment_data['txn_details'] = serialize($myPaypal->ipnData);
        $payment_data['txn_id'] = $myPaypal->ipnData['txn_id'];
        if ($myPaypal->ipnData['payment_status'] == 'Completed' || $myPaypal->ipnData['payment_status'] == 'Pending') {
            $payment_data['payment_status'] = 'Completed';
            if ($paypal_settings['use_sandbox']) {
                // For this, we'll just email ourselves ALL the data as plain text output.
                $subject = 'Instant Payment Notification - Gateway Variable Dump';
                $body = "An instant payment notification was successfully recieved\n";
                $body .= "from " . $myPaypal->ipnData['payer_email'] . " on " . date('m/d/Y');
                $body .= " at " . date('g:i A') . "\n\nDetails:\n";
                foreach ($myPaypal->ipnData as $key => $value) {
                    $body .= "\n{$key}: {$value}\n";
                }
                wp_mail($payment_data['contact'], $subject, $body);
            }
        } else {
            $subject = 'Instant Payment Notification - Gateway Variable Dump';
            $body = "An instant payment notification failed\n";
            $body .= "from " . $myPaypal->ipnData['payer_email'] . " on " . date('m/d/Y');
            $body .= " at " . date('g:i A') . "\n\nDetails:\n";
            foreach ($myPaypal->ipnData as $key => $value) {
                $body .= "\n{$key}: {$value}\n";
            }
            wp_mail($payment_data['contact'], $subject, $body);
        }
    }
    $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data);
    $payment_data = apply_filters('filter_hook_espresso_update_attendee_payment_data_in_db', $payment_data);
    do_action('action_hook_espresso_email_after_payment', $payment_data);
    return $payment_data;
}
예제 #3
0
 public function verificationAction()
 {
     /*
      - check payment type use switch if necessary (paypal, twoco, manual )
      - use verification function from existing library of paypal/twoco
      - set order status if verified
      - redirect to proper page? or trigger mail?          
     */
     // Create an instance of the paypal library
     require_once 'PaymentGateway/Paypal.php';
     $myPaypal = new Paypal();
     // Log the IPN results
     $myPaypal->ipnLog = TRUE;
     // Enable test mode if needed
     if ($this->_testMode) {
         $myPaypal->enableTestMode();
     }
     // Check validity, status, amount and tax amount and write down it
     if ($myPaypal->validateIpn()) {
         //if ($myPaypal->ipnData['payment_status'] == 'Completed' && $myPaypal['']=='')
         if ($myPaypal->ipnData['payment_status'] == 'Completed') {
             $data = $myPaypal->ipnData;
             //$this->Mailer($data['custom'], 'admin-paypal', 'admin');
             //$this->Mailer($data['custom'], 'user-paypal', 'XXX');
             $this->paypalsave('SUCCESS', $data);
             $modDir = $this->getFrontController()->getModuleDirectory();
             require_once $modDir . '/models/Store/Mailer.php';
             $mod = new Holsite_Model_Store_Mailer();
             $mod->sendReceiptToUser($data['custom'], 'paypal', 'SUCCESS PAID');
         } else {
             $data = $myPaypal->ipnData;
             //$this->Mailer($data['custom'], 'admin-paypal', 'admin');
             //$this->Mailer($data['custom'], 'user-paypal', 'admin');
             $this->paypalsave('FAILED', $data);
             $modDir = $this->getFrontController()->getModuleDirectory();
             require_once $modDir . '/models/Store/Mailer.php';
             $mod = new Holsite_Model_Store_Mailer();
             $mod->sendReceiptToUser($data['custom'], 'paypal', 'FAILED');
         }
     } else {
         foreach ($this->_request->getParams() as $key => $val) {
             $data[$key] = $val;
         }
         //all data and key are same with ipnData
         //$this->Mailer($data['custom'], 'admin-paypal', 'admin');
         //send all post variables to admin email
         $writer = new Zend_Log_Writer_Stream(ROOT_PATH . '/app_log.txt');
         $logger = new Zend_Log($writer);
         $logger->info(var_dump($data));
     }
     die;
 }
예제 #4
0
<?php

define("IN_KEKE", true);
require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'app_comm.php';
require "Paypal.php";
$myPaypal = new Paypal();
$myPaypal->logIpn = TRUE;
$valid = $myPaypal->validateIpn();
list($_, $charge_type, $uid, $obj_id, $order_id, $model_id) = explode('-', $myPaypal->ipnData['custom'], 6);
$fac_obj = new pay_return_fac_class($charge_type, $model_id, $uid, $obj_id, $order_id, $myPaypal->ipnData['mc_gross'], 'paypal', $myPaypal->ipnData['custom']);
if ($valid) {
    $total_fee = $myPaypal->ipnData['mc_fee'];
    if ($myPaypal->ipnData['payment_status'] == 'Completed') {
        $response = $fac_obj->load();
        if ($charge_type == 'user_charge') {
            $show_url = 'index.php?do=recharge&cash=' . $total_fee . '&status=1';
        } elseif ($charge_type == 'payitem_charge') {
            if (!in_array($model_id, array(6, 7))) {
                $show_url = 'index.php?do=task&id=' . $obj_id;
            } else {
                $show_url = 'index.php?do=goods&id=' . $obj_id;
            }
        } else {
            if (!in_array($model_id, array(6, 7))) {
                $arrOrderDetail = keke_order_class::get_order_detail($order_id);
                if ($arrOrderDetail[0]['obj_type'] == 'hosted') {
                    $show_url = 'index.php?do=task&id=' . $obj_id;
                } else {
                    $show_url = 'index.php?do=pay&type=task&id=' . $obj_id . '&status=1';
                }
            } else {
 public function gateway_ipn($config)
 {
     $cancel = $this->EE->input->get('cancel', TRUE);
     $ipn_valid = FALSE;
     if ($cancel != '') {
         $this->EE->product_model->cart_update_status(session_id(), 0);
         $this->EE->functions->redirect($this->EE->functions->create_url($this->_config["store"][$this->site_id]["cart_url"]));
         exit;
     }
     // Create an instance of the paypal library
     $myPaypal = new Paypal();
     if ($config["sandbox"] == "TRUE") {
         $myPaypal->enableTestMode();
     }
     # Debug file_put_contents(APPPATH.'cache/brilliant_retail/paypal_'.time().'.txt', 'SUCCESS\n\n'.json_encode($_POST));
     // Check validity and write down it
     if ($myPaypal->validateIpn()) {
         $ipn_valid = TRUE;
     }
     // Update BR
     if ($myPaypal->ipnData['payment_status'] == 'Completed' || $myPaypal->ipnData['payment_status'] == 'Pending') {
         if ($ipn_valid == TRUE) {
             $status['Pending'] = 2;
             $status['Completed'] = 3;
             $new_status = $status[$myPaypal->ipnData['payment_status']];
         } else {
             $new_status = 1;
         }
         // The ipn_create_order funtion is a core
         // function that will 'create' the order
         // based on the merchant_id value stored in the br_order_table.
         // Function handles both creating and updating from pending to complete
         // just pass the merchant_id. For paypal standard it is in the custom field.
         $this->ipn_create_order($myPaypal->ipnData['custom'], $new_status);
     }
     @header("HTTP/1.0 200 OK");
     @header("HTTP/1.1 200 OK");
     exit('Success');
 }
예제 #6
0
 public function verificationAction()
 {
     /*
      - check payment type use switch if necessary (paypal, twoco, manual )
      - use verification function from existing library of paypal/twoco
      - set order status if verified
      - redirect to proper page? or trigger mail?          
     */
     // Create an instance of the paypal library
     require_once 'PaymentGateway/Paypal.php';
     $myPaypal = new Paypal();
     // Log the IPN results
     $myPaypal->ipnLog = TRUE;
     // Enable test mode if needed
     if ($this->_testMode) {
         $myPaypal->enableTestMode();
     }
     // Check validity, status, amount and tax amount and write down it
     if ($myPaypal->validateIpn()) {
         //if ($myPaypal->ipnData['payment_status'] == 'Completed' && $myPaypal['']=='')
         if ($myPaypal->ipnData['payment_status'] == 'Completed') {
             $data = $myPaypal->ipnData;
             $this->Mailer($data['custom'], 'admin-paypal', 'admin');
             $this->Mailer($data['custom'], 'user-paypal', 'admin');
             $this->paypalsave('SUCCESS', $data);
         } else {
             $data = $myPaypal->ipnData;
             $this->Mailer($data['custom'], 'admin-paypal', 'admin');
             $this->Mailer($data['custom'], 'user-paypal', 'admin');
             $this->paypalsave('FAILED', $data);
             /*$this->paypalsave('FAILED');
             	 $this->Mailer($data['orderId'], 'admin-paypal', 'admin');
             	 $this->Mailer($data['orderId'], 'user-paypal', 'admin');*/
         }
     } else {
         foreach ($this->_request->getParams() as $key => $val) {
             $data[$key] = $val;
         }
         //all data and key are same with ipnData
         $this->Mailer($data['custom'], 'admin-paypal', 'admin');
         //send all post variables to admin email
     }
     $_SESSION['jCart'] = '';
     die;
 }
예제 #7
0
 public function actionIpn()
 {
     Yii::import('application.modules.shop.components.payment.Paypal');
     $paypal = new Paypal();
     Shop::log('Paypal payment attempt');
     // Log the IPN results
     $paypal->ipnLog = TRUE;
     if (Shop::module()->payPalTestMode) {
         $paypal->enableTestMode();
     }
     // Check validity and write down it
     if ($paypal->validateIpn()) {
         if ($paypal->ipnData['payment_status'] == 'Completed') {
             Shop::log('Paypal payment arrived :' . var_dump($paypal));
         } else {
             Shop::log('Paypal payment raised an error :' . var_dump($paypal));
         }
     }
 }
예제 #8
0
<?php

// Include the paypal library
include_once 'Paypal.php';
// Create an instance of the paypal library
$myPaypal = new Paypal();
// Log the IPN results
$myPaypal->ipnLog = TRUE;
// Enable test mode if needed
$myPaypal->enableTestMode();
// Check validity and write down it
if ($myPaypal->validateIpn()) {
    if ($myPaypal->ipnData['payment_status'] == 'Completed') {
        file_put_contents('paypal.txt', 'SUCCESS');
    } else {
        file_put_contents('paypal.txt', "FAILURE\n\n" . $myPaypal->ipnData);
    }
}