/** * Ipn::paypal() * * Validate PayPal payments * * @access public * @return void */ public function paypal() { // Include the paypal library include_once APPPATH . 'libraries/payment/Paypal.php'; $this->_gateway = 1; // Create an instance of the paypal library $my_paypal = new Paypal(); // Log the IPN results // $my_paypal->ipn_log = TRUE; // Enable test mode if needed if (defined('XUDEBUG') and XUDEBUG == true) { $my_paypal->enable_test_mode(); } // Check validity and write down it if ($my_paypal->validate_ipn()) { if ($my_paypal->ipn_data['payment_status'] == 'Completed') { $settings = json_decode(base64_decode($my_paypal->ipn_data['custom'])); if ($settings['type'] == 'reg') { $this->_new_user_payment($settings['user_id'], $my_paypal->ipn_data['amount']); redirect('/user/pay_complete'); } redirect('/user/pay_cancel'); } else { $this->_log_error($my_paypal->ipn_data); redirect('/user/pay_cancel'); } } redirect('/user/pay_cancel'); }
function paypal_ipn($id) { $order = ORM::factory("order")->where("id", "=", $id)->find(); if ($order->loaded()) { $paypal = new Paypal(); if ($paypal->validate_ipn($id)) { if ($paypal->ipn_data['payment_status'] == "Completed") { $order->status = Order_Model::PAYMENT_CONFIRMED; order_log::log($order, order_log::ORDERED); // send e-mails basket::send_order($order); basket::send_invoice($order); $order->save(); } return; } print "invalid access. tut tut!"; } return; }
function paymentPaypalIpn($order_id) { $product_id = self::GetOrderValue('order_product', $order_id); if (empty($product_id)) { die; //return 'alert("'.$_ARRAYLANG['TXT_EGOV_ERROR_PROCESSING_ORDER']."\");\n"; } $objPaypal = new Paypal(); if (!self::GetProduktValue('product_paypal', $product_id)) { // How did we get here? PayPal isn't even enabled for this product. die; //return 'alert("'.$_ARRAYLANG['TXT_EGOV_PAYPAL_NOT_VALID']."\");\n"; } if (self::GetSettings('set_paypal_ipn') == 0) { // PayPal IPN is disabled. die; //return ''; } if (!$objPaypal->validate_ipn()) { // Verification failed. die; //return 'alert("'.$_ARRAYLANG['TXT_EGOV_PAYPAL_NOT_VALID']."\");\n"; } /* // PayPal IPN Confirmation by email $subject = 'Instant Payment Notification - Recieved Payment'; $to = self::GetProduktValue('product_paypal_sandbox', $product_id); $body = "An instant payment notification was successfully recieved\n"; $body .= "from ".$objPaypal->ipn_data['payer_email']." on ".date('m/d/Y'); $body .= " at ".date('g:i A')."\n\nDetails:\n"; foreach ($objPaypal->ipn_data as $key => $value) { $body .= "\n$key: $value"; } mail($to, $subject, $body); */ // Update the order silently. $this->updateOrder($order_id); }
function paypal_ipn($id) { $order = ORM::factory("bp_order")->where("id", "=", $id)->find(); if ($order->loaded()) { $paypal = new Paypal(); if ($paypal->validate_ipn($id)) { if ($paypal->ipn_data['payment_status'] == "Completed") { $order->status = Bp_Order_Model::PAYMENT_CONFIRMED; bp_order_log::log($order, Bp_Order_Log_Model::ORDERED); // send e-mails to customer and internal order handling basket_plus::send_order($order); $order->save(); } return; } print "invalid access. tut tut!"; } return; }
<?php require_once dirname(dirname(dirname(__FILE__))) . '/app.php'; $_input_charset = 'utf-8'; $partner = $INI['paypal']['mid']; $security_code = $INI['paypal']['sec']; $sign_type = 'MD5'; $transport = 'http'; $paypal = new Paypal(); //$paypal->add_field(); $verify_result = $paypal->validate_ipn(); $out_trade_no = $_POST['item_number']; //$total_fee = $_POST['amount']; @(list($_, $order_id, $city_id, $_) = explode('-', $out_trade_no, 4)); $payment_status = $_POST['payment_status']; // Pending - Completed - Denied - Refunded $total_fee = $_POST['mc_gross']; $currency = $_POST['mc_currency']; // $total = $paypal->ipn_data["mc_gross"]; // already get verified, update local data. if ($verify_result) { // $total = $_POST['amount']; if ($payment_status == 'Completed' || $payment_status == 'Pending') { $order = Table::Fetch('order', $order_id); if ($order['state'] == 'unpay') { //1 $table = new Table('order'); $table->SetPk('id', $order_id); $table->pay_id = $out_trade_no; $table->money = $total_fee; $table->state = 'pay';
<?php //Include the common file require_once '../../common.php'; //Initialize object $paypal = new Paypal(); //Validate ipn $paypal->validate_ipn($_POST); //Check ipn transaction if (!$paypal->is_verified()) { $paypal->log_response(); die; } //Switch action switch ($paypal->get_payment_status()) { case 'Pending': $paypal->log_payment("Pending Payment"); break; case 'Completed': $paypal->log_payment("Completed Payment"); $values = array('order_status_description_id' => '2'); $where = array('order_id' => $paypal->get_order_id()); $db->where($where); $db->update(config_item('cart', 'table_orders'), $values); foreach ($db->query("SELECT order_digital_good_id, number_days FROM " . config_item('cart', 'table_order_digital_goods') . " WHERE order_id = '" . $paypal->get_order_id() . "'") as $row) { if ($row['number_days'] > 0) { $values = array('date_expiration' => time() + $row['number_days'] * 3600 * 24); } else { $values = array('date_expiration' => 0); } $where = array('order_id' => $paypal->get_order_id(), 'order_digital_good_id' => $row['order_digital_good_id']);